mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
FindAdv: Amend 652ffc9c(2): Fix handling search for whole words if in mathed.
Didn't know, how to get char-value cursor is pointing to. Hopefully someone knows a better way as in this patch.
This commit is contained in:
parent
52c5084d63
commit
0d6e3bcdc3
@ -4831,6 +4831,10 @@ static int findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, Ma
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isWordChar(char_type c)
|
||||||
|
{
|
||||||
|
return isLetterChar(c) || isDigitASCII(c);
|
||||||
|
}
|
||||||
|
|
||||||
/// Perform a FindAdv operation.
|
/// Perform a FindAdv operation.
|
||||||
bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
|
bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
|
||||||
@ -4860,7 +4864,7 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
|
|||||||
if (opt.matchword && cur.pos() > 0) { // 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()) {
|
if (cur.inTexted()) {
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
if ((cur.pos() > 0) && !par.isWordSeparator(cur.pos() -1, true)) {
|
if (!par.isWordSeparator(cur.pos() -1, true)) {
|
||||||
class Text *t = cur.text();
|
class Text *t = cur.text();
|
||||||
CursorSlice to;
|
CursorSlice to;
|
||||||
CursorSlice from = cur.top();
|
CursorSlice from = cur.top();
|
||||||
@ -4870,7 +4874,37 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur.inMathed()) {
|
else if (cur.inMathed()) {
|
||||||
cur.pos() = cur.lastpos();
|
// Check if 'cur.pos()-1' and 'cur.pos()' both point to a letter,
|
||||||
|
// I am not sure, we should consider the selection
|
||||||
|
bool sel = bv->cursor().selection();
|
||||||
|
if (!sel && cur.pos() < cur.lastpos()) {
|
||||||
|
CursorSlice const & cs = cur.top();
|
||||||
|
MathData md = cs.cell();
|
||||||
|
int len = -1;
|
||||||
|
MathData::const_iterator it_end = md.end();
|
||||||
|
MathData md2;
|
||||||
|
// Start the check with one character before actual cursor position
|
||||||
|
for (MathData::const_iterator it = md.begin() + cs.pos() - 1;
|
||||||
|
it != it_end; ++it)
|
||||||
|
md2.push_back(*it);
|
||||||
|
docstring inp = asString(md2);
|
||||||
|
LYXERR0("Got \"" << inp << "\"");
|
||||||
|
char_type prev = inp[0];
|
||||||
|
for (len = 0; (unsigned) len < inp.size() && len + cur.pos() <= cur.lastpos(); len++) {
|
||||||
|
char_type c = inp[len];
|
||||||
|
if (isLetterChar(c))
|
||||||
|
continue;
|
||||||
|
if (isDigitASCII(c))
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// len == 0 means previous char was a word separator
|
||||||
|
// len == 1 search starts with a word separator
|
||||||
|
// len == 2 ... we have to skip len -1 chars
|
||||||
|
if (len > 1)
|
||||||
|
cur.pos() = cur.pos() + len - 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
opt.matchword = false;
|
opt.matchword = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user