Skip to content

Commit eb4a55c

Browse files
authored
Fix find and replace index reset (#838)
1 parent a87db6b commit eb4a55c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

addons/dialogue_manager/components/find_in_files.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func update_results_view() -> void:
9999
var matched_word: String = "[bgcolor=" + colors.critical_color.to_html() + "][color=" + colors.text_color.to_html() + "]" + path_result.matched_text + "[/color][/bgcolor]"
100100
highlight = "[s]" + matched_word + "[/s][bgcolor=" + colors.notice_color.to_html() + "][color=" + colors.text_color.to_html() + "]" + replace_input.text + "[/color][/bgcolor]"
101101
else:
102-
highlight = "[bgcolor=" + colors.symbols_color.to_html() + "][color=" + colors.text_color.to_html() + "]" + path_result.matched_text + "[/color][/bgcolor]"
102+
highlight = "[bgcolor=" + colors.notice_color.to_html() + "][color=" + colors.text_color.to_html() + "]" + path_result.matched_text + "[/color][/bgcolor]"
103103
var text: String = path_result.text.substr(0, path_result.index) + highlight + path_result.text.substr(path_result.index + path_result.query.length())
104104
result_label.text = "%s: %s" % [str(path_result.line).lpad(4), text]
105105
result_label.gui_input.connect(func(event):

addons/dialogue_manager/components/search_and_replace.gd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func find_in_line(line: String, text: String, from_index: int = 0) -> int:
114114
return line.findn(text, from_index)
115115

116116

117-
### Signals
117+
#region Signals
118118

119119

120120
func _on_text_edit_gui_input(event: InputEvent) -> void:
@@ -177,14 +177,17 @@ func _on_replace_button_pressed() -> void:
177177

178178
# Replace the selection at result index
179179
var r: Array = results[result_index]
180+
code_edit.begin_complex_operation()
180181
var lines: PackedStringArray = code_edit.text.split("\n")
181182
var line: String = lines[r[0]]
182183
line = line.substr(0, r[1]) + replace_input.text + line.substr(r[1] + r[2])
183184
lines[r[0]] = line
184185
code_edit.text = "\n".join(lines)
185-
search(input.text, result_index)
186+
code_edit.end_complex_operation()
186187
code_edit.text_changed.emit()
187188

189+
search(input.text, result_index)
190+
188191

189192
func _on_replace_all_button_pressed() -> void:
190193
if match_case_button.button_pressed:
@@ -210,3 +213,6 @@ func _on_input_focus_entered() -> void:
210213

211214
func _on_match_case_check_box_toggled(button_pressed: bool) -> void:
212215
search()
216+
217+
218+
#endregion

0 commit comments

Comments
 (0)