mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Now backslash-prefixed regexps like "\s", "\d", etc., are all understood by Advanced F&R.
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
This commit is contained in:
parent
5a4f151fb8
commit
c7e609135a
10
development/autotests/findadv-18-in.txt
Normal file
10
development/autotests/findadv-18-in.txt
Normal file
@ -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
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user