From 8028dce12910cd7cac4d872488603c225a3070a0 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Fri, 29 May 2020 14:22:34 +0200 Subject: [PATCH] FindAdv: Correct some testcases --- development/autotests/findadv-05-in.txt | 3 ++- development/autotests/findadv-06-in.txt | 5 ++++- development/autotests/findadv-07-in.txt | 2 ++ development/autotests/findadv-09-in.txt | 2 ++ development/autotests/findadv-10-in.txt | 2 ++ development/autotests/findadv-11-in.txt | 1 + development/autotests/findadv-14-in.txt | 2 ++ development/autotests/findadv-15-in.txt | 2 ++ development/autotests/findadv-re-01-in.txt | 3 +++ src/lyxfind.cpp | 11 ++++++++--- 10 files changed, 28 insertions(+), 5 deletions(-) diff --git a/development/autotests/findadv-05-in.txt b/development/autotests/findadv-05-in.txt index 0fcf149af5..1f4ba89d79 100644 --- a/development/autotests/findadv-05-in.txt +++ b/development/autotests/findadv-05-in.txt @@ -3,13 +3,14 @@ Lang sk_SK.utf8 CO: findadv-05.ctrl TestBegin test.lyx -dbg key,find > findadv-05.loga.txt 2>&1 -KD: 50 +KD: 100 CN: Part 1 KK: foo \Cefoo foo\Ce foo\C\[Home] KK: \Cs KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF # Select emphasised KK: \Ce KK: foo\[Return] diff --git a/development/autotests/findadv-06-in.txt b/development/autotests/findadv-06-in.txt index 3fb38b61f6..164df32cc1 100644 --- a/development/autotests/findadv-06-in.txt +++ b/development/autotests/findadv-06-in.txt @@ -14,6 +14,7 @@ KK: \Axbuffer-write\[Return] KK: \Axdialog-show findreplaceadv\[Return] # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Aj KK: \Ao2 KK: foo\[Return] @@ -26,9 +27,11 @@ KK: \Axdialog-show findreplaceadv\[Return] KK: \[Delete] # Uncheck ignore format #KK: \At\Ai\Ah +#KK: \CF KK: \Ao9 -KK: foo\[Return]\[Return] +KK: foo\[Return]\[Return]\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n with len: 3 +CP: Putting selection at .*idx: 0 par: 1 pos: 0\n with len: 3 CP: Putting selection at .*idx: 0 par: 2 pos: 0\n with len: 3 TestEnd Lang C diff --git a/development/autotests/findadv-07-in.txt b/development/autotests/findadv-07-in.txt index 37c5b7623a..77f6b8b2d3 100644 --- a/development/autotests/findadv-07-in.txt +++ b/development/autotests/findadv-07-in.txt @@ -15,6 +15,7 @@ KK: \Axbuffer-write\[Return] KK: \Axdialog-show findreplaceadv\[Return] # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Aob Sleep 1 KK: foo\[Return] @@ -27,6 +28,7 @@ KK: \CF KK: \[Delete] # Uncheck ignore format #KK: \At\Ai\Ah +#KK: \CF KK: \Aob Sleep 1 KK: bar\[Return] diff --git a/development/autotests/findadv-09-in.txt b/development/autotests/findadv-09-in.txt index 10de532daa..48d1b2bd44 100644 --- a/development/autotests/findadv-09-in.txt +++ b/development/autotests/findadv-09-in.txt @@ -9,6 +9,7 @@ KK: one\[Return]two\[Return]three\C\[Home]\Cs KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Aob KK: \Axregexp-mode\[Return][a-z]* \[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n with len: 3 @@ -20,6 +21,7 @@ KK: \CF KK: \[Delete] # Uncheck ignore format #KK: \At\Ai\Ah +#KK: \CF KK: \Aob KK: \Axregexp-mode\[Return][a-z]* \[Return]\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n with len: 3 diff --git a/development/autotests/findadv-10-in.txt b/development/autotests/findadv-10-in.txt index f4eb288b86..8ff7df9ac4 100644 --- a/development/autotests/findadv-10-in.txt +++ b/development/autotests/findadv-10-in.txt @@ -11,6 +11,7 @@ KK: \Cs KK: \CF # Uncheck ignore format (depends on IT language) KK: \At\Ai\Ah +KK: \CF KK: LyX\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 8\n with len: 3 # @@ -21,6 +22,7 @@ KK: \CF KK: \[Delete] # Uncheck ignore format #KK: \At\Ai\Ah +#KK: \CF KK: LaTeX\[Return] CP: Putting selection at .*idx: 0 par: 1 pos: 10\n with len: 5 TestEnd diff --git a/development/autotests/findadv-11-in.txt b/development/autotests/findadv-11-in.txt index a13d81c8ac..81f1184092 100644 --- a/development/autotests/findadv-11-in.txt +++ b/development/autotests/findadv-11-in.txt @@ -21,6 +21,7 @@ KK: \CF KK: \[Delete] # Uncheck ignore format KK: \Az\Ag\Ae +KK: \CF KK: \Cm KK: v\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n.*idx: 1 par: 0 pos: 0\n with len: 1 diff --git a/development/autotests/findadv-14-in.txt b/development/autotests/findadv-14-in.txt index 022238a434..c35371d1c6 100644 --- a/development/autotests/findadv-14-in.txt +++ b/development/autotests/findadv-14-in.txt @@ -12,6 +12,7 @@ KK: \Cs KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Amd KK: x^2\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n with len: 1 @@ -33,6 +34,7 @@ CP: Key (queried) [action=buffer-begin][Ctrl+Home] KK: \CF KK: \[Delete] KK: \At\Ai\Ah +KK: \CF KK: \Amd KK: x^2\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n with len: 1 diff --git a/development/autotests/findadv-15-in.txt b/development/autotests/findadv-15-in.txt index cfe6be47e4..7a4899dbc6 100644 --- a/development/autotests/findadv-15-in.txt +++ b/development/autotests/findadv-15-in.txt @@ -13,6 +13,7 @@ KK: \Cs KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \C\[F22] KK: x^2\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n with len: 1 @@ -35,6 +36,7 @@ KK: \CF KK: \[Delete] # Check ignore format (was unchecked) KK: \At\Ai\Ah +KK: \CF KK: \C\[F22] KK: x^2\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n with len: 1 diff --git a/development/autotests/findadv-re-01-in.txt b/development/autotests/findadv-re-01-in.txt index 468b17d75a..667b77c61c 100644 --- a/development/autotests/findadv-re-01-in.txt +++ b/development/autotests/findadv-re-01-in.txt @@ -1,6 +1,7 @@ # Finding special latex/regexp chars: ( # Lang it_IT.utf8 +KD: 100 CO: findadv-re-01.ctrl TestBegin test.lyx -dbg key,find > findadv-re-01.loga.txt 2>&1 CN: Part 1 @@ -18,6 +19,7 @@ CN: Part 2 KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Axregexp-mode\[Return]\\(\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 1\n with len: 1 TestEnd @@ -40,6 +42,7 @@ CN: Part 4 KK: \CF # Uncheck ignore format KK: \At\Ai\Ah +KK: \CF KK: \Axregexp-mode\[Return]\\[\[Return] CP: Putting selection at .*idx: 0 par: 0 pos: 3\n with len: 1 TestEnd diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index b9633bc7f9..c65d2ca7c0 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -968,7 +968,7 @@ static size_t identifyLeading(string const & s) // + allow to search for colored text too while (regex_replace(t, t, REGEX_BOS "\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage|latexenvironment)\\{[a-z]+\\*?\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{", "") || regex_replace(t, t, REGEX_BOS "\\$", "") - || regex_replace(t, t, REGEX_BOS "\\\\\\[ ", "") + || regex_replace(t, t, REGEX_BOS "\\\\\\[", "") || regex_replace(t, t, REGEX_BOS " ?\\\\item\\{[a-z]+\\}", "") || regex_replace(t, t, REGEX_BOS "\\\\begin\\{[a-zA-Z_]*\\*?\\} ", "")) ; @@ -2711,7 +2711,7 @@ static int identifyClosing(string & t) LYXERR(Debug::FIND, "identifyClosing(): t now is '" << t << "'"); if (regex_replace(t, t, "(.*[^\\\\])\\$" REGEX_EOS, "$1")) continue; - if (regex_replace(t, t, "(.*[^\\\\]) \\\\\\]" REGEX_EOS, "$1")) + if (regex_replace(t, t, "(.*[^\\\\])\\\\\\]" REGEX_EOS, "$1")) continue; if (regex_replace(t, t, "(.*[^\\\\]) \\\\end\\{[a-zA-Z_]*\\*?\\}" REGEX_EOS, "$1")) continue; @@ -3040,9 +3040,14 @@ MatchResult MatchStringAdv::operator()(DocIterator const & cur, int len, bool at bool ws_left = (cur.pos() > 0) ? par.isWordSeparator(cur.pos() - 1) : true; - bool ws_right = (cur.pos() + len < par.size()) + bool ws_right; + if (len < 0) + ws_right = true; + else { + ws_right = (cur.pos() + len < par.size()) ? par.isWordSeparator(cur.pos() + len) : true; + } LYXERR(Debug::FIND, "cur.pos()=" << cur.pos() << ", res=" << res << ", separ: " << ws_left << ", " << ws_right -- 2.39.5