From 2337149eb5e9c7b0c2ed593ebf70922e849acd0a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 9 Jun 2021 21:53:41 +0200 Subject: [PATCH] Macro IDE: replace-and-find only replaces if current selection is matching search expression --- src/lay/lay/layMacroEditorPage.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lay/lay/layMacroEditorPage.cc b/src/lay/lay/layMacroEditorPage.cc index 10003778b..a770ccd3e 100644 --- a/src/lay/lay/layMacroEditorPage.cc +++ b/src/lay/lay/layMacroEditorPage.cc @@ -1135,7 +1135,11 @@ MacroEditorPage::replace_and_find_next (const QString &replace) QTextCursor c = mp_text->textCursor (); if (c.hasSelection ()) { - c.insertText (interpolate_string (replace, m_current_search)); + QTextBlock b = c.block (); + int o = std::max (0, c.position () - b.position ()); + if (m_current_search.indexIn (b.text (), o) == o) { + c.insertText (interpolate_string (replace, m_current_search)); + } } find_next ();