cur.recordUndo();
int striked = ssize -
cur.paragraph().eraseChars(pos, pos + match_len,
- buf.params().trackChanges);
+ buf.params().track_changes);
cur.paragraph().insert(pos, replacestr, font,
- Change(buf.params().trackChanges
+ Change(buf.params().track_changes
? Change::INSERTED
: Change::UNCHANGED));
for (int i = 0; i < rsize + striked; ++i)
if (!cur.inTexted())
// bail in math
return make_pair(false, 0);
- // select current word and treat it as the search string
+ // select current word and treat it as the search string.
+ // This causes a minor bug as undo will restore this selection,
+ // which the user did not create (#8986).
cur.innerText()->selectWord(cur, WHOLE_WORD);
searchstr = cur.selectionAsString(false);
}
// of this function). This will avoid changes to be selected half.
bool search_both_sides = false;
Cursor tmpcur = cur;
- // Leave math first
+ // Find enclosing text cursor
while (tmpcur.inMathed())
tmpcur.pop_back();
Change change_next_pos
= tmpcur.paragraph().lookupChange(tmpcur.pos());
- if (change_next_pos.changed() && cur.inMathed()) {
- cur = tmpcur;
- search_both_sides = true;
- } else if (tmpcur.pos() > 0 && tmpcur.inTexted()) {
- Change change_prev_pos
- = tmpcur.paragraph().lookupChange(tmpcur.pos() - 1);
- if (change_next_pos.isSimilarTo(change_prev_pos))
+ if (change_next_pos.changed()) {
+ if (cur.inMathed()) {
+ cur = tmpcur;
search_both_sides = true;
+ } else if (tmpcur.pos() > 0 && tmpcur.inTexted()) {
+ Change change_prev_pos
+ = tmpcur.paragraph().lookupChange(tmpcur.pos() - 1);
+ if (change_next_pos.isSimilarTo(change_prev_pos))
+ search_both_sides = true;
+ }
}
+ // find the next change
if (!findChange(cur, next))
return false;
CursorSlice & tip = cur.top();
- if (!next)
+ if (!next && tip.pos() > 0)
// take a step into the change
tip.backwardPos();
runparams.flavor = OutputParams::LATEX;
runparams.linelen = 100000; //lyxrc.plaintext_linelen;
runparams.dryrun = true;
+ runparams.for_search = true;
for (pos_type pit = pos_type(0); pit < (pos_type)buffer.paragraphs().size(); ++pit) {
Paragraph const & par = buffer.paragraphs().at(pit);
LYXERR(Debug::FIND, "Adding to search string: '"
- << par.stringify(pos_type(0), par.size(),
- AS_STR_INSETS, runparams)
+ << par.asString(pos_type(0), par.size(),
+ AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT,
+ &runparams)
<< "'");
- str += par.stringify(pos_type(0), par.size(),
- AS_STR_INSETS, runparams);
+ str += par.asString(pos_type(0), par.size(),
+ AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT,
+ &runparams);
}
}
return str;
runparams.dryrun = true;
LYXERR(Debug::FIND, "Stringifying with cur: "
<< cur << ", from pos: " << cur.pos() << ", end: " << end);
- return par.stringify(cur.pos(), end, AS_STR_INSETS, runparams);
+ return par.asString(cur.pos(), end,
+ AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT,
+ &runparams);
} else if (cur.inMathed()) {
docstring s;
CursorSlice cs = cur.top();
DocIterator sel_beg = cur.selectionBegin();
DocIterator sel_end = cur.selectionEnd();
if (&sel_beg.inset() != &sel_end.inset()
- || sel_beg.pit() != sel_end.pit())
+ || sel_beg.pit() != sel_end.pit()
+ || sel_beg.idx() != sel_end.idx())
return;
int sel_len = sel_end.pos() - sel_beg.pos();
LYXERR(Debug::FIND, "sel_beg: " << sel_beg << ", sel_end: " << sel_end