mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 16:31:13 +00:00
FindAdv: Amend 627cd6de
: Use '~' instead of "\\ " for search if possible
Also fix a thinko in interpreting the found values. The match_len describes the length of the second regex field, while matchend is the length of the search field 0.
This commit is contained in:
parent
627cd6dec2
commit
4bb427a244
@ -579,7 +579,10 @@ void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
{
|
{
|
||||||
switch (params_.kind) {
|
switch (params_.kind) {
|
||||||
case InsetSpaceParams::NORMAL:
|
case InsetSpaceParams::NORMAL:
|
||||||
os << (runparams.free_spacing && (runparams.for_search == OutputParams::NoSearch) ? " " : "\\ ");
|
if (runparams.for_search != OutputParams::NoSearch)
|
||||||
|
os << "~";
|
||||||
|
else
|
||||||
|
os << (runparams.free_spacing ? " " : "\\ ");
|
||||||
break;
|
break;
|
||||||
case InsetSpaceParams::PROTECTED:
|
case InsetSpaceParams::PROTECTED:
|
||||||
if (runparams.local_font &&
|
if (runparams.local_font &&
|
||||||
|
@ -831,10 +831,6 @@ string string2regex(string in)
|
|||||||
blanks++;
|
blanks++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else if (tempx[i] == '\\' && tempx[i+1] == '\\' && tempx[i+2] == ' ') {
|
|
||||||
blanks++;
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (blanks > 0) {
|
if (blanks > 0) {
|
||||||
temp += "\\s+";
|
temp += "\\s+";
|
||||||
@ -3740,6 +3736,9 @@ MatchResult MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_be
|
|||||||
if (lng != str.size()) {
|
if (lng != str.size()) {
|
||||||
str = str.substr(0, lng);
|
str = str.substr(0, lng);
|
||||||
}
|
}
|
||||||
|
// Replace occurences of '~' to ' '
|
||||||
|
static std::regex specialChars { R"(~)" };
|
||||||
|
str = std::regex_replace(str, specialChars, R"( )" );
|
||||||
}
|
}
|
||||||
if (str.empty()) {
|
if (str.empty()) {
|
||||||
mres.match_len = -1;
|
mres.match_len = -1;
|
||||||
@ -3808,7 +3807,7 @@ MatchResult MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_be
|
|||||||
while (mres.match_len > 0) {
|
while (mres.match_len > 0) {
|
||||||
QChar c = qstr.at(matchend - 1);
|
QChar c = qstr.at(matchend - 1);
|
||||||
if ((c == '\n') || (c == '}') || (c == '{')) {
|
if ((c == '\n') || (c == '}') || (c == '{')) {
|
||||||
mres.match_len--;
|
// mres.match_len--;
|
||||||
matchend--;
|
matchend--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3837,7 +3836,7 @@ MatchResult MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_be
|
|||||||
while (mres.match_len > 0) {
|
while (mres.match_len > 0) {
|
||||||
char c = str.at(matchend - 1);
|
char c = str.at(matchend - 1);
|
||||||
if ((c == '\n') || (c == '}') || (c == '{')) {
|
if ((c == '\n') || (c == '}') || (c == '{')) {
|
||||||
mres.match_len--;
|
// mres.match_len--;
|
||||||
matchend--;
|
matchend--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user