From e20531bcb0cdd582c82a5083f917fb1b94557087 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 2 Apr 2010 16:21:25 -0400 Subject: Fixed snippets bug with Lua code %n sequences; modules/textadept/lsnippets.lua --- modules/textadept/lsnippets.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/textadept/lsnippets.lua') diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua index 2e2d4ced..92f1b0a5 100644 --- a/modules/textadept/lsnippets.lua +++ b/modules/textadept/lsnippets.lua @@ -362,7 +362,9 @@ function insert(s_text) snippet.start_pos = start or caret snippet.prev_sel_text = buffer:get_sel_text() snippet.index, snippet.max_index = 0, 0 - for i in s_text:gmatch('%%(%d+)') do + for i in s_text:gsub('(%%%d+)%b()', '%1'):gmatch('%%(%d+)') do + -- placeholders may contain Lua code that has %n sequences that mess up + -- this calculation; the above gsub accounts for this i = tonumber(i) if i > snippet.max_index then snippet.max_index = i end end -- cgit v1.2.3