mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Workaround for advanced search in 'uncover'-inset.
Allows for matches inside style Uncover if used Settings->Adhere to search string formatting This does not cover all of #12594 though.
This commit is contained in:
parent
75d10993c9
commit
9be6a425df
@ -902,7 +902,7 @@ string correctRegex(string t, bool withformat)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sub.str(4) == "backslash") {
|
if (sub.str(4) == "backslash") {
|
||||||
replace = "\\";
|
replace = string("\\");
|
||||||
{
|
{
|
||||||
// transforms '\backslash \{' into '\{'
|
// transforms '\backslash \{' into '\{'
|
||||||
string next = t.substr(sub.position(2) + sub.str(2).length(), 2);
|
string next = t.substr(sub.position(2) + sub.str(2).length(), 2);
|
||||||
@ -4372,15 +4372,20 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
{
|
{
|
||||||
if (!cur)
|
if (!cur)
|
||||||
return 0;
|
return 0;
|
||||||
bool repeat = false;
|
int repeat = 0;
|
||||||
DocIterator orig_cur; // to be used if repeat not successful
|
DocIterator orig_cur; // to be used if repeat not successful
|
||||||
MatchResult orig_mres;
|
MatchResult orig_mres;
|
||||||
|
do {
|
||||||
|
orig_cur = cur;
|
||||||
|
cur.forwardPos();
|
||||||
|
} while (cur.depth() > orig_cur.depth());
|
||||||
|
cur = orig_cur;
|
||||||
while (!theApp()->longOperationCancelled() && cur) {
|
while (!theApp()->longOperationCancelled() && cur) {
|
||||||
//(void) findAdvForwardInnermost(cur);
|
//(void) findAdvForwardInnermost(cur);
|
||||||
LYXERR(Debug::FINDVERBOSE, "findForwardAdv() cur: " << cur);
|
LYXERR(Debug::FINDVERBOSE, "findForwardAdv() cur: " << cur);
|
||||||
MatchResult mres = match(cur, -1, MatchStringAdv::MatchAnyPlace);
|
MatchResult mres = match(cur, -1, MatchStringAdv::MatchAnyPlace);
|
||||||
string msg = "Starting";
|
string msg = "Starting";
|
||||||
if (repeat)
|
if (repeat > 0)
|
||||||
msg = "Repeated";
|
msg = "Repeated";
|
||||||
displayMres(mres, msg + " findForwardAdv", cur)
|
displayMres(mres, msg + " findForwardAdv", cur)
|
||||||
int match_len = mres.match_len;
|
int match_len = mres.match_len;
|
||||||
@ -4389,8 +4394,13 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
match_len = 0;
|
match_len = 0;
|
||||||
}
|
}
|
||||||
if (match_len <= 0) {
|
if (match_len <= 0) {
|
||||||
// This should exit nested insets, if any, or otherwise undefine the currsor.
|
if (repeat > 0) {
|
||||||
cur.pos() = cur.lastpos();
|
repeat--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This should exit nested insets, if any, or otherwise undefine the currsor.
|
||||||
|
cur.pos() = cur.lastpos();
|
||||||
|
}
|
||||||
LYXERR(Debug::FINDVERBOSE, "Advancing pos: cur=" << cur);
|
LYXERR(Debug::FINDVERBOSE, "Advancing pos: cur=" << cur);
|
||||||
cur.forwardPos();
|
cur.forwardPos();
|
||||||
}
|
}
|
||||||
@ -4418,7 +4428,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
cur.pos() = cur.pos() + increment;
|
cur.pos() = cur.pos() + increment;
|
||||||
MatchResult mres2 = match(cur, -1, MatchStringAdv::MatchAnyPlace);
|
MatchResult mres2 = match(cur, -1, MatchStringAdv::MatchAnyPlace);
|
||||||
displayMres(mres2, "findForwardAdv loop", cur)
|
displayMres(mres2, "findForwardAdv loop", cur)
|
||||||
switch (interpretMatch(mres, mres2)) {
|
switch (interpretMatch(mres, mres2)) {
|
||||||
case MatchResult::newIsTooFar:
|
case MatchResult::newIsTooFar:
|
||||||
// behind the expected match
|
// behind the expected match
|
||||||
firstInvalid = increment;
|
firstInvalid = increment;
|
||||||
@ -4426,7 +4436,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
increment /= 2;
|
increment /= 2;
|
||||||
break;
|
break;
|
||||||
case MatchResult::newIsBetter:
|
case MatchResult::newIsBetter:
|
||||||
// not reached yet, but cur.pos()+increment is bettert
|
// not reached yet, but cur.pos()+increment is better
|
||||||
mres = mres2;
|
mres = mres2;
|
||||||
firstInvalid -= increment;
|
firstInvalid -= increment;
|
||||||
if (increment > firstInvalid*3/4)
|
if (increment > firstInvalid*3/4)
|
||||||
@ -4449,14 +4459,14 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
if (mres.match_len > 0) {
|
if (mres.match_len > 0) {
|
||||||
if (mres.match_prefix + mres.pos - mres.leadsize > 0) {
|
if (mres.match_prefix + mres.pos - mres.leadsize > 0) {
|
||||||
// The match seems to indicate some deeper level
|
// The match seems to indicate some deeper level
|
||||||
repeat = true;
|
repeat = 2;
|
||||||
orig_cur = cur;
|
orig_cur = cur;
|
||||||
orig_mres = mres;
|
orig_mres = mres;
|
||||||
cur.forwardPos();
|
cur.forwardPos();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (repeat) {
|
else if (repeat > 0) {
|
||||||
// should never be reached.
|
// should never be reached.
|
||||||
cur = orig_cur;
|
cur = orig_cur;
|
||||||
mres = orig_mres;
|
mres = orig_mres;
|
||||||
|
Loading…
Reference in New Issue
Block a user