Skip to content

Commit 5aa6935

Browse files
committed
Refresh results when match options change
Re-run the current search when Match Case, Whole Word, or Regex is toggled so the selection and result feedback update immediately. Add regression coverage for each search option.
1 parent b073a13 commit 5aa6935

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎MeadowPy/dev/tests/test_ui_panels_and_dialogs.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,20 @@ def test_find_replace_bar_uses_editor_selection_and_replace_workflows(qapp):
997997
editor.find_first_calls.clear()
998998
editor.find_first_results = [False]
999999
bar._case_btn.setChecked(True)
1000+
assert editor.find_first_calls[-1][:6] == (
1001+
"needle", False, True, False, True, True
1002+
)
1003+
assert bar._match_label.text() == "No results"
1004+
1005+
editor.find_first_results = [True]
10001006
bar._word_btn.setChecked(True)
1007+
assert editor.find_first_calls[-1][:6] == (
1008+
"needle", False, True, True, True, True
1009+
)
1010+
assert bar._match_label.text() == ""
1011+
1012+
editor.find_first_results = [False]
10011013
bar._regex_btn.setChecked(True)
1002-
bar.find_next()
10031014
assert editor.find_first_calls[-1][:6] == ("needle", True, True, True, True, True)
10041015
assert bar._match_label.text() == "No results"
10051016

‎MeadowPy/meadowpy/ui/find_replace_bar.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def _setup_ui(self) -> None:
5050
self._case_btn = self._make_toggle("Aa", "Match Case")
5151
self._word_btn = self._make_toggle("W", "Match Whole Word")
5252
self._regex_btn = self._make_toggle(".*", "Use Regular Expression")
53+
for toggle in (self._case_btn, self._word_btn, self._regex_btn):
54+
toggle.toggled.connect(self._on_match_option_toggled)
5355

5456
self._match_label = QLabel("")
5557
self._match_label.setMinimumWidth(40)
@@ -285,6 +287,10 @@ def _on_find_text_changed(self, text: str) -> None:
285287
else:
286288
self._match_label.setText("")
287289

290+
def _on_match_option_toggled(self, _checked: bool) -> None:
291+
"""Refresh the current search after a match option changes."""
292+
self.find_next()
293+
288294
def _get_editor(self) -> CodeEditor | None:
289295
return self._window._tab_manager.current_editor()
290296

0 commit comments

Comments
 (0)