aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/editing.lua15
-rw-r--r--modules/textadept/lsnippets.lua25
-rw-r--r--modules/textadept/snippets.lua14
3 files changed, 44 insertions, 10 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index e7cc684b..1631ca59 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -154,15 +154,18 @@ function autocomplete_word(word_chars)
local buffer_text = buffer:get_text(length)
local root = buffer_text:sub(1, caret):match('['..word_chars..']+$')
if not root or #root == 0 then return end
- local match_pos = buffer:find(root, 1048580) -- word start and match case
- while match_pos do
+ buffer.target_start, buffer.target_end = 0, buffer.length
+ buffer.search_flags = 1048580 -- word start and match case
+ local match_pos = buffer:search_in_target(root)
+ while match_pos ~= -1 do
local s, e = buffer_text:find('^['..word_chars..']+', match_pos + 1)
local match = buffer_text:sub(s, e)
if not completions[match] and #match > #root then
c_list[#c_list + 1] = match
completions[match] = true
end
- match_pos = buffer:find(root, 1048580, match_pos + 1)
+ buffer.target_start, buffer.target_end = match_pos + 1, buffer.length
+ match_pos = buffer:search_in_target(root)
end
if #c_list > 0 then buffer:auto_c_show(#root, table.concat(c_list, ' ')) end
end
@@ -498,7 +501,11 @@ function select_enclosed(str)
while s >= 0 do
char = string.char(buffer.char_at[s])
if char_matches[char] then
- local _, e = buffer:find(char_matches[char], 0, e)
+ buffer.target_start, buffer.target_end = e, buffer.length
+ buffer.search_flags = 0
+ if buffer:search_in_target(char_matches[char]) ~= -1 then
+ e = buffer.target_end
+ end
if e then buffer:set_sel(s + 1, e - 1) break end
end
s = s - 1
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index ee7a394b..c0cfab20 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -227,17 +227,29 @@ function next()
if index <= snippet.max_index then
local s, e, next_item = s_text:find('%%'..index..'(%b())')
if next_item and not next_item:find('|') then -- placeholder
- s, e = buffer:find('%'..index..next_item, 0, s_start)
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ buffer.search_flags = 0
+ s = buffer:search_in_target('%'..index..next_item)
+ e = buffer.target_end
next_item = next_item:gsub('#(%b())', run_lua_code)
next_item = unhandle_escapes(next_item:sub(2, -2))
buffer:set_sel(s, e)
buffer:replace_sel(next_item)
buffer:set_sel(s, s + #next_item)
else -- use the first mirror as a placeholder
- s, e = buffer:find('%'..index..'[^(]', 2097152, s_start) -- regexp
+ s, e = nil, nil
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ buffer.search_flags = 2097152 -- regexp
+ if buffer:search_in_target('%'..index..'[^(]') ~= -1 then
+ s, e = buffer.target_start, buffer.target_end
+ end
if not s and not e then
+ s, e = nil, nil
-- Scintilla cannot match [\r\n\f] in regexp mode; use '$' instead
- s, e = buffer:find('%'..index..'$', 2097152, s_start) -- regexp
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ if buffer:search_in_target('%'..index..'$') ~= -1 then
+ s, e = buffer.target_start, buffer.target_end
+ end
if e then e = e + 1 end
end
if not s then snippet.index = index + 1 return next() end
@@ -255,7 +267,12 @@ function next()
buffer:goto_pos(s_end + 1)
buffer:delete_back()
end
- local s, e = buffer:find('%__caret', 4, s_start)
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ buffer.search_flags = 4
+ local s, e
+ if buffer:search_in_target('%__caret') ~= -1 then
+ s, e = buffer.target_start, buffer.target_end
+ end
if s and s <= s_end then
buffer:set_sel(s, e)
buffer:replace_sel('')
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index 8d46610e..d9d40f71 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -251,7 +251,12 @@ next_snippet_item = function()
if s and next_item then
next_item = unescape(next_item)
_DEBUG('next_item:\n'..next_item)
- local s, e = buffer:find(next_item, 0, s_start)
+ local s, e
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ buffer.search_flags = 0
+ if buffer:search_in_target(next_item) ~= -1 then
+ s, e = buffer.target_start, buffer.target_end
+ end
if s and e then
buffer:set_sel(s, e)
snippet.cursor = s
@@ -283,7 +288,12 @@ next_snippet_item = function()
join_lines()
end
- local s, e = buffer:find('$CURSOR', 4, s_start)
+ local s, e
+ buffer.target_start, buffer.target_end = s_start, buffer.length
+ buffer.search_flags = 4
+ if buffer:search_in_target('$CURSOR') ~= -1 then
+ s, e = buffer.target_start, buffer.target_end
+ end
if s and e then
buffer:set_sel(s, e)
buffer:replace_sel('')