Applying (variation of) fix by stwitt to solve #7172.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37043 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2010-12-29 19:59:41 +00:00
parent 4d367ac00a
commit fab8c264aa
2 changed files with 9 additions and 3 deletions

View File

@ -330,11 +330,11 @@ void FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt)
dispatch(cmd);
LYXERR(Debug::FIND, "dispatched");
if (bv->cursor().result().dispatched()) {
// Match found, selected and replaced if needed
// New match found and selected (old selection replaced if needed)
return;
}
// No match found in current buffer:
// No match found in current buffer (however old selection might have been replaced)
// select next buffer in scope, if any
bool prompt = nextPrevBuffer(buf, opt);
if (prompt) {
@ -367,6 +367,9 @@ void FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt)
lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
buf_orig->absFileName()));
bv = view_.documentBufferView();
// This may happen after a replace occurred
if (cur_orig.pos() > cur_orig.lastpos())
cur_orig.pos() = cur_orig.lastpos();
bv->cursor().setCursor(cur_orig);
}

View File

@ -1203,9 +1203,11 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
cap::cutSelection(cur, false, false);
if (!cur.inMathed()) {
LYXERR(Debug::FIND, "Replacing by pasteParagraphList()ing repl_buffer");
LYXERR(Debug::FIND, "Before pasteParagraphList() cur=" << cur << endl);
cap::pasteParagraphList(cur, repl_buffer.paragraphs(),
repl_buffer.params().documentClassPtr(),
bv->buffer().errorList("Paste"));
LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
} else {
odocstringstream ods;
OutputParams runparams(&repl_buffer.params().encoding());
@ -1226,6 +1228,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
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);
}
@ -1235,7 +1238,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt)
{
DocIterator cur;
int match_len;
int match_len = 0;
if (opt.search.empty()) {
bv->message(_("Search text is empty!"));