Support partial unhighlight selection
This commit is contained in:
@@ -329,7 +329,7 @@ func _highlight_range(start: int, end: int) -> void:
|
|||||||
if start == end:
|
if start == end:
|
||||||
return
|
return
|
||||||
|
|
||||||
if _remove_overlapping_highlights(highlights, start, end):
|
if _subtract_highlight_range(highlights, start, end):
|
||||||
_render_stem()
|
_render_stem()
|
||||||
if stem_label.has_method("deselect"):
|
if stem_label.has_method("deselect"):
|
||||||
stem_label.deselect()
|
stem_label.deselect()
|
||||||
@@ -370,14 +370,21 @@ func _escape_bbcode(value: String) -> String:
|
|||||||
return value.replace("[", "[lb]").replace("]", "[rb]")
|
return value.replace("[", "[lb]").replace("]", "[rb]")
|
||||||
|
|
||||||
|
|
||||||
func _remove_overlapping_highlights(highlights: Array, start: int, end: int) -> bool:
|
func _subtract_highlight_range(highlights: Array, start: int, end: int) -> bool:
|
||||||
var removed := false
|
var changed := false
|
||||||
for index in range(highlights.size() - 1, -1, -1):
|
for index in range(highlights.size() - 1, -1, -1):
|
||||||
var highlight_range: Dictionary = highlights[index]
|
var highlight_range: Dictionary = highlights[index]
|
||||||
if start < int(highlight_range.get("end", 0)) and end > int(highlight_range.get("start", 0)):
|
var highlight_start := int(highlight_range.get("start", 0))
|
||||||
|
var highlight_end := int(highlight_range.get("end", 0))
|
||||||
|
if start < highlight_end and end > highlight_start:
|
||||||
highlights.remove_at(index)
|
highlights.remove_at(index)
|
||||||
removed = true
|
if highlight_start < start:
|
||||||
return removed
|
highlights.insert(index, {"start": highlight_start, "end": start})
|
||||||
|
index += 1
|
||||||
|
if end < highlight_end:
|
||||||
|
highlights.insert(index, {"start": end, "end": highlight_end})
|
||||||
|
changed = true
|
||||||
|
return changed
|
||||||
|
|
||||||
|
|
||||||
func _apply_saved_choice_state() -> void:
|
func _apply_saved_choice_state() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user