From 07e233209961e5e557e50b379133161cde000c02 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 30 Mar 2010 20:11:43 -0400 Subject: Use multiple carets for snippets; modules/textadept/lsnippets.lua --- modules/textadept/lsnippets.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/textadept/lsnippets.lua') 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. -- cgit v1.2.3