]> git.lyx.org Git - features.git/blobdiff - src/Paragraph.cpp
Consider inset strings in simple find/replaceAll (#12049)
[features.git] / src / Paragraph.cpp
index 1b6a766fb54f6a7d289bc7eeb443260ff0f25c7f..994098df484582bb48e876138917566a2bf2ac11 100644 (file)
@@ -4388,6 +4388,13 @@ int Paragraph::find(docstring const & str, bool cs, bool mw,
        int i = 0;
        pos_type const parsize = d->text_.size();
        for (i = 0; i < strsize && pos < parsize; ++i, ++pos) {
+               // ignore deleted matter
+               if (!del && isDeleted(pos)) {
+                       if (pos == parsize - 1)
+                               break;
+                       pos++;
+                       continue;
+               }
                // Ignore "invisible" letters such as ligature breaks
                // and hyphenation chars while searching
                while (pos < parsize - 1 && isInset(pos)) {
@@ -4396,16 +4403,19 @@ int Paragraph::find(docstring const & str, bool cs, bool mw,
                                break;
                        odocstringstream os;
                        inset->toString(os);
-                       if (!os.str().empty())
-                               break;
+                       if (!os.str().empty()) {
+                               int const insetstringsize = os.str().length();
+                               for (int j = 0; j < insetstringsize && pos < parsize; ++i, ++j) {
+                                       if (str[i] != os.str()[j])
+                                               break;
+                               }
+                       }
                        pos++;
                }
                if (cs && str[i] != d->text_[pos])
                        break;
                if (!cs && uppercase(str[i]) != uppercase(d->text_[pos]))
                        break;
-               if (!del && isDeleted(pos))
-                       break;
        }
 
        if (i != strsize)