aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-02-15 00:29:20 -0500
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-02-15 00:29:20 -0500
commit7def99140aa8d9e3a4cdd0b678afed9adea95b69 (patch)
treed6124487ae272adf1a32cf5ed027a1c6c411c466 /modules
parenta81fbc0b621aef0eae640be3dc453eda409c70c2 (diff)
Fixed inability to replace found text with escapes like '\n' and '\t'.
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/find.lua7
1 files changed, 4 insertions, 3 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.