]> git.lyx.org Git - features.git/commitdiff
Fixing regression bug after last commit. Couldn't find anything better, however now...
authorTommaso Cucinotta <tommaso@lyx.org>
Wed, 26 Jan 2011 23:54:12 +0000 (23:54 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Wed, 26 Jan 2011 23:54:12 +0000 (23:54 +0000)
(when replacing text which is longer than the replaced contents in math mode and similar).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37335 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfind.cpp

index a594703d91874a9f7cf97276930e11bbcd89c932..752aaaec5b8fc9dd025672835d24a24101dc5f75 100644 (file)
@@ -1216,7 +1216,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
                                        repl_buffer.params().documentClassPtr(),
                                        bv->buffer().errorList("Paste"));
                LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
-               cur.pos() -= repl_buffer.paragraphs().begin()->size();
+               sel_len = repl_buffer.paragraphs().begin()->size();
        } else {
                odocstringstream ods;
                OutputParams runparams(&repl_buffer.params().encoding());
@@ -1234,10 +1234,13 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
                regex_replace(s, s, "\\\\\\[(.*)\\\\\\]", "$1");
                repl_latex = from_utf8(s);
                LYXERR(Debug::FIND, "Replacing by niceInsert()ing latex: '" << repl_latex << "'");
-               cur.niceInsert(repl_latex);
+               sel_len = cur.niceInsert(repl_latex);
        }
-       LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << repl_buffer.paragraphs().begin()->size());
-       bv->putSelectionAt(DocIterator(cur), repl_buffer.paragraphs().begin()->size(), !opt.forward);
+       cur.pos() -= sel_len;
+       if (cur.pos() < 0)
+               cur.pos() = 0;
+       LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << sel_len);
+       bv->putSelectionAt(DocIterator(cur), sel_len, !opt.forward);
        bv->processUpdateFlags(Update::Force);
 }