Support partial unhighlight selection

This commit is contained in:
hz
2026-07-09 21:48:34 -05:00
parent bb29fcf14c
commit 1822c00a3b
+13 -6
View File
@@ -329,7 +329,7 @@ func _highlight_range(start: int, end: int) -> void:
if start == end:
return
if _remove_overlapping_highlights(highlights, start, end):
if _subtract_highlight_range(highlights, start, end):
_render_stem()
if stem_label.has_method("deselect"):
stem_label.deselect()
@@ -370,14 +370,21 @@ func _escape_bbcode(value: String) -> String:
return value.replace("[", "[lb]").replace("]", "[rb]")
func _remove_overlapping_highlights(highlights: Array, start: int, end: int) -> bool:
var removed := false
func _subtract_highlight_range(highlights: Array, start: int, end: int) -> bool:
var changed := false
for index in range(highlights.size() - 1, -1, -1):
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)
removed = true
return removed
if highlight_start < start:
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: