FindAdv: Simplify search for chars '&', '%', '#' and '_'

This is not possible for '$', because of the latex-meaning to
start/end math inset.
Therefore, if not ignoring format, we still have to use
[\\][\$] in regex in order to find '$' in text.
This commit is contained in:
Kornel Benko 2018-12-05 13:36:43 +01:00
parent 131f4b92ba
commit cd94180492
3 changed files with 26 additions and 10 deletions

View File

@ -1297,9 +1297,17 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
column += 14;
break;
case '$': case '&':
case '%': case '#': case '{':
case '}': case '_':
case '&':
case '%': case '#':
case '_':
if (runparams.for_search) {
os.put(c);
column += 1;
break;
}
// fall through
case '$':
case '{': case '}':
os << '\\';
os.put(c);
column += 1;

View File

@ -74,19 +74,19 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
os << '{';
}
odocstringstream ourplain;
InsetText::plaintext(ourplain, runparams);
odocstringstream ourlatex;
otexstream ots(ourlatex);
InsetText::latex(ots, runparams);
if (runparams.for_search) {
// No need for special handling, if we are only searching for some patterns
os << ourplain.str() << "}";
os << ourlatex.str() << "}";
return;
}
// get contents of InsetText as LaTeX and plaintext
odocstringstream ourlatex;
odocstringstream ourplain;
InsetText::plaintext(ourplain, runparams);
// FIXME: do Tex/Row correspondence (I don't currently understand what is
// being generated from latexstr below)
otexstream ots(ourlatex);
InsetText::latex(ots, runparams);
docstring latexstr = ourlatex.str();
docstring plainstr = ourplain.str();

View File

@ -1442,8 +1442,16 @@ void LatexInfo::buildEntries(bool isPatternString)
if (key == "") {
if (sub.str(0)[0] == '\\')
key = sub.str(0)[1];
else
else {
key = sub.str(0);
if (key == "$") {
size_t k_pos = sub.position(size_t(0));
if ((k_pos > 0) && (interval.par[k_pos - 1] == '\\')) {
// Escaped '$', ignoring
continue;
}
}
}
};
if (evaluatingRegexp) {
if (sub.str(1).compare("endregexp") == 0) {