From 38ea16b279aa4f5b355a01040415f67ed2888d8c Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 10 Nov 2013 15:28:34 -0500 Subject: Store the full Lua pattern match in "%0" for use in replacement text. --- modules/textadept/find.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index ed8950f0..76897309 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -144,6 +144,7 @@ local function find_(text, next, flags, no_wrap, wrapped) M.captures = {table.unpack(caps, next and 3 or 4)} if #caps > 0 and caps[2] >= caps[1] then pos, e = s + caps[next and 1 or 3] - 1, s + caps[2] + M.captures[0] = buffer:text_range(pos, e) buffer:set_sel(e, pos) end end @@ -259,7 +260,7 @@ local function replace(rtext) buffer:target_from_selection() rtext = rtext:gsub('%%%%', '\\037') -- escape '%%' if M.captures then - for i = 1, #M.captures do + for i = 0, #M.captures do rtext = rtext:gsub('%%'..i, (M.captures[i]:gsub('%%', '%%%%'))) end end -- cgit v1.2.3