aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/lsnippets.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-03-30 20:11:43 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-03-30 20:11:43 -0400
commit07e233209961e5e557e50b379133161cde000c02 (patch)
treecb7af250f037df91abe5a41aaaef09efa234f6dc /modules/textadept/lsnippets.lua
parentcc13d3e2c10e684543e1ebdd4a56daede7fe7565 (diff)
downloadtextadept-07e233209961e5e557e50b379133161cde000c02.tar.gz
textadept-07e233209961e5e557e50b379133161cde000c02.zip
Use multiple carets for snippets; modules/textadept/lsnippets.lua
Diffstat (limited to 'modules/textadept/lsnippets.lua')
-rw-r--r--modules/textadept/lsnippets.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index 9eb999ea..2e2d4ced 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -275,6 +275,19 @@ local function next_tab_stop()
buffer:replace_sel('') -- replace_target() doesn't place caret
snippet.ph_pos = s_start + s - 1
end
+ -- Place additional carets at mirrors.
+ local _, _, text = snippet_info()
+ text = text:gsub('(%%%d+%b())',
+ function(mirror)
+ -- Lua code in replacement mirrors may contain '%' sequences; do not
+ -- treat as mirrors
+ if mirror:find('|') then return string.rep('_', #mirror) end
+ end)
+ for s, e in text:gmatch('()%%'..index..'()[^(]') do
+ buffer:add_selection(s_start + s - 1, s_start + e - 1)
+ end
+ buffer.main_selection = 0 -- original placeholder/mirror
+ -- Done.
snippet.index = index
else
-- Finished. Find '%0' and place the caret there.