aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-04-02 16:21:25 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-04-02 16:21:25 -0400
commite20531bcb0cdd582c82a5083f917fb1b94557087 (patch)
tree319bf6d74bdc884e671971f4b67f72c6b19339d3
parent80a5769ed86611adf5390e126a4628a13dbcabbe (diff)
downloadtextadept-e20531bcb0cdd582c82a5083f917fb1b94557087.tar.gz
textadept-e20531bcb0cdd582c82a5083f917fb1b94557087.zip
Fixed snippets bug with Lua code %n sequences; modules/textadept/lsnippets.lua
-rw-r--r--modules/textadept/lsnippets.lua4
1 files changed, 3 insertions, 1 deletions
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