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) {
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);
}
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());
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);
}
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!"));