FindAdv: Amend 652ffc9c: have to check inTexted() before using Paragraph

This commit is contained in:
Kornel Benko 2022-05-26 17:17:49 +02:00
parent 1ef1808c93
commit 567d0e8fb4

View File

@ -4857,16 +4857,21 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
num_replaced += findAdvReplace(bv, opt, matchAdv);
cur = bv->cursor();
if (opt.forward) {
if (opt.matchword) { // Skip word-characters if we are in the mid of a word
if (opt.matchword && cur.pos() > 0) { // Skip word-characters if we are in the mid of a word
if (cur.inTexted()) {
Paragraph const & par = cur.paragraph();
if ((cur.pos() > 0) && !par.isWordSeparator(cur.pos() -1, true)) {
while (cur.pos() < par.size()) {
if (par.isWordSeparator(cur.pos(), true))
break;
else
cur.forwardPos();
class Text *t = cur.text();
CursorSlice to;
CursorSlice from = cur.top();
t->getWord(from, to, WHOLE_WORD);
cur.pos() = to.pos();
cur.pit() = to.pit();
}
}
else if (cur.inMathed()) {
cur.pos() = cur.lastpos();
}
opt.matchword = false;
}
pos_len = findForwardAdv(cur, matchAdv);