diff options
-rw-r--r-- | modules/textadept/find.lua | 7 | ||||
-rw-r--r-- | test/test.lua | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 72c806fa..31624503 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -372,13 +372,14 @@ function M.find_in_files(dir, filter) end local P, V, C, upper, lower = lpeg.P, lpeg.V, lpeg.C, string.upper, string.lower +local esc = {b = '\b', f = '\f', n = '\n', r = '\r', t = '\t', v = '\v'} local re_patt = lpeg.Cs(P{ - (V('text') + V('u') + V('l') + V('U') + V('L'))^1, - text = (1 - '\\' * lpeg.S('uUlLE'))^1, + (V('text') + V('u') + V('l') + V('U') + V('L') + V('esc'))^1, + text = (1 - '\\' * lpeg.S('uUlLEbfnrtv'))^1, u = '\\u' * C(1) / upper, l = '\\l' * C(1) / lower, U = P('\\U') / '' * (V('text') / upper + V('u') + V('l'))^0 * V('E')^-1, L = P('\\L') / '' * (V('text') / lower + V('u') + V('l'))^0 * V('E')^-1, - E = P('\\E') / '' + E = P('\\E') / '', esc = '\\' * C(1) / esc }) -- Returns string *text* with the following sequences unescaped: -- * "\uXXXX" sequences replaced with the equivalent UTF-8 character. diff --git a/test/test.lua b/test/test.lua index 5d09a514..3bd20223 100644 --- a/test/test.lua +++ b/test/test.lua @@ -2653,7 +2653,8 @@ function test_find_replace_regex_transforms() ['f\\1ba\\L\\2'] = 'foObarbaz', ['f\\1ba\\U\\l\\2'] = 'foObarBaz', [''] = 'az', - ['\\0'] = 'foObaRbaz' + ['\\0'] = 'foObaRbaz', + ['\\r\\n\\t'] = '\r\n\taz' } for regex, replacement in pairs(replacements) do ui.find.replace_entry_text = regex |