Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.

Commit f11f797

Browse files
committed
Merge branch 'master' of github.com:mu-editor/mu
2 parents 195fcf8 + 4dc0a11 commit f11f797

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

mu/interface/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ def replace_text(self, target_text, replace, global_replace):
11741174
if global_replace:
11751175
counter = 0
11761176
found = self.current_tab.findFirst(
1177-
target_text, True, True, False, False, line=0, index=0
1177+
target_text, False, True, False, False, line=0, index=0
11781178
)
11791179
if found:
11801180
counter += 1
@@ -1185,7 +1185,7 @@ def replace_text(self, target_text, replace, global_replace):
11851185
return counter
11861186
else:
11871187
found = self.current_tab.findFirst(
1188-
target_text, True, True, False, True
1188+
target_text, False, True, False, True
11891189
)
11901190
if found:
11911191
self.current_tab.replace(replace)
@@ -1207,7 +1207,7 @@ def highlight_text(self, target_text, forward=True):
12071207
line, index, _el, _ei = self.current_tab.getSelection()
12081208
return self.current_tab.findFirst(
12091209
target_text, # Text to find,
1210-
True, # Treat as regular expression
1210+
False, # Treat as regular expression
12111211
True, # Case sensitive search
12121212
False, # Whole word matches only
12131213
True, # Wrap search

tests/interface/test_main.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,22 @@ def test_Window_replace_text_global_missing():
18281828
assert w.replace_text("foo", "bar", True) == 0
18291829

18301830

1831+
def test_Window_replace_text_highlight_text_correct_selection():
1832+
"""
1833+
Check that replace_text and highlight_text are actually highlighting text
1834+
without regex matching.
1835+
"""
1836+
view = mu.interface.main.Window()
1837+
text = "ofafefifoof."
1838+
tab = mu.interface.editor.EditorPane("path", text)
1839+
with mock.patch("mu.interface.Window.current_tab") as current:
1840+
current.findFirst = tab.findFirst
1841+
view.highlight_text("f.")
1842+
assert tab.selectedText() == "f."
1843+
assert view.replace_text("of.", "", False)
1844+
assert tab.selectedText() == "of."
1845+
1846+
18311847
def test_Window_highlight_text():
18321848
"""
18331849
Given target_text, highlights the first instance via Scintilla's findFirst
@@ -1841,7 +1857,7 @@ def test_Window_highlight_text():
18411857
mock_tab.getSelection.return_value = 0, 0, 0, 0
18421858
assert w.highlight_text("foo")
18431859
mock_tab.findFirst.assert_called_once_with(
1844-
"foo", True, True, False, True, forward=True, index=-1, line=-1
1860+
"foo", False, True, False, True, forward=True, index=-1, line=-1
18451861
)
18461862

18471863

@@ -1858,7 +1874,7 @@ def test_Window_highlight_text_backward():
18581874
mock_tab.getSelection.return_value = 0, 0, 0, 0
18591875
assert w.highlight_text("foo", forward=False)
18601876
mock_tab.findFirst.assert_called_once_with(
1861-
"foo", True, True, False, True, forward=False, index=0, line=0
1877+
"foo", False, True, False, True, forward=False, index=0, line=0
18621878
)
18631879

18641880

0 commit comments

Comments
 (0)