]> git.lyx.org Git - features.git/commitdiff
Puts the selection at the correct position after replacing math contents with Advance...
authorTommaso Cucinotta <tommaso@lyx.org>
Wed, 26 Jan 2011 23:06:02 +0000 (23:06 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Wed, 26 Jan 2011 23:06:02 +0000 (23:06 +0000)
Fixes crashes reported as #7245 and also #7241.

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

src/lyxfind.cpp

index 73b9df371885cb7a63c8e6f7d56f1bd62dc7befc..a594703d91874a9f7cf97276930e11bbcd89c932 100644 (file)
@@ -1107,6 +1107,7 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) {
 docstring stringifyFromForSearch(FindAndReplaceOptions const & opt,
        DocIterator const & cur, int len)
 {
+       LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(), /* */);
        if (!opt.ignoreformat)
                return latexifyFromCursor(cur, len);
        else
@@ -1215,6 +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();
        } else {
                odocstringstream ods;
                OutputParams runparams(&repl_buffer.params().encoding());
@@ -1234,7 +1236,6 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
                LYXERR(Debug::FIND, "Replacing by niceInsert()ing latex: '" << repl_latex << "'");
                cur.niceInsert(repl_latex);
        }
-       cur.pos() -= repl_buffer.paragraphs().begin()->size();
        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);
        bv->processUpdateFlags(Update::Force);