]> git.lyx.org Git - features.git/commitdiff
Now backslash-prefixed regexps like "\s", "\d", etc., are all understood by Advanced...
authorTommaso Cucinotta <tommaso@lyx.org>
Sun, 12 Jun 2011 00:12:26 +0000 (00:12 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sun, 12 Jun 2011 00:12:26 +0000 (00:12 +0000)
Fixing issue 4 reported at: http://permalink.gmane.org/gmane.editors.lyx.devel/136992

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39016 a592a061-630c-0410-9148-cb99ea01b6c8

development/autotests/findadv-18-in.txt [new file with mode: 0644]
src/lyxfind.cpp

diff --git a/development/autotests/findadv-18-in.txt b/development/autotests/findadv-18-in.txt
new file mode 100644 (file)
index 0000000..15b998d
--- /dev/null
@@ -0,0 +1,10 @@
+# Searching for regexp with e.g. \[Backspace]\[Backspace]s finds blanks
+
+Lang it_IT.utf8
+TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
+KK: a b c\C\[Home]
+KK: \Cs
+KK: \CF
+KK: \Axregexp-mode\[Return]\\\\s\[Return]
+TestEnd
+Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 1\n with len: 1' lyx-log.txt
index 86d8b9818189f11ded597a7e93c991317e18d07c..adce89cb9d08d308ce35edc97496b5cd53393f7c 100644 (file)
@@ -518,6 +518,7 @@ Escapes const & get_lyx_unescapes() {
                escape_map.push_back(pair<string, string>("{[}", "["));
                escape_map.push_back(pair<string, string>("\\$", "$"));
                escape_map.push_back(pair<string, string>("\\backslash{}", "\\"));
+               escape_map.push_back(pair<string, string>("\\backslash ", "\\"));
                escape_map.push_back(pair<string, string>("\\backslash", "\\"));
                escape_map.push_back(pair<string, string>("\\sim ", "~"));
                escape_map.push_back(pair<string, string>("\\^", "^"));
@@ -567,7 +568,8 @@ size_t find_matching_brace(string const & s, size_t pos)
        return s.size();
 }
 
-/// Within \regexp{} apply get_regex_escapes(), while outside apply get_lyx_unescapes().
+/// Within \regexp{} apply get_lyx_unescapes() only (i.e., preserve regexp semantics of the string),
+/// while outside apply get_lyx_unescapes()+get_regexp_escapes().
 string escape_for_regex(string s)
 {
        size_t pos = 0;
@@ -577,9 +579,9 @@ string escape_for_regex(string s)
                        new_pos = s.size();
                LYXERR(Debug::FIND, "new_pos: " << new_pos);
                string t = apply_escapes(s.substr(pos, new_pos - pos), get_lyx_unescapes());
-               LYXERR(Debug::FIND, "t      : " << t);
+               LYXERR(Debug::FIND, "t [lyx]: " << t);
                t = apply_escapes(t, get_regexp_escapes());
-               LYXERR(Debug::FIND, "t      : " << t);
+               LYXERR(Debug::FIND, "t [rxp]: " << t);
                s.replace(pos, new_pos - pos, t);
                new_pos = pos + t.size();
                LYXERR(Debug::FIND, "Regexp after escaping: " << s);