diff options
author | 2010-03-30 20:11:43 -0400 | |
---|---|---|
committer | 2010-03-30 20:11:43 -0400 | |
commit | 07e233209961e5e557e50b379133161cde000c02 (patch) | |
tree | cb7af250f037df91abe5a41aaaef09efa234f6dc | |
parent | cc13d3e2c10e684543e1ebdd4a56daede7fe7565 (diff) | |
download | textadept-07e233209961e5e557e50b379133161cde000c02.tar.gz textadept-07e233209961e5e557e50b379133161cde000c02.zip |
Use multiple carets for snippets; modules/textadept/lsnippets.lua
-rw-r--r-- | modules/textadept/lsnippets.lua | 13 |
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. |