aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept')
-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