diff options
author | 2014-06-09 14:35:19 -0400 | |
---|---|---|
committer | 2014-06-09 14:35:19 -0400 | |
commit | 107d2613c1a8d31ac2d6df3732229c283cea98d7 (patch) | |
tree | a6fcc671e9fc81c9b5b1e2d6ef5dfe9dc445766a | |
parent | e56735ed361d707618c8c45b56efffd51194ef30 (diff) | |
download | textadept-107d2613c1a8d31ac2d6df3732229c283cea98d7.tar.gz textadept-107d2613c1a8d31ac2d6df3732229c283cea98d7.zip |
Fixed word autocompletion bug when ignoring case; modules/textadept/editing.lua
-rw-r--r-- | modules/textadept/editing.lua | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 883cbabc..b6235195 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -543,14 +543,19 @@ M.autocompleters.word = function() local word_char = '['..buffer.word_chars:gsub('(%p)', '%%%1')..']' local word = line:sub(1, pos):match(word_char..'*$') if word == '' then return nil end - if ignore_case then word = word:lower() end + local word_patt = word:gsub('(%p)', '%%%1') + if ignore_case then + word_patt = word_patt:lower():gsub('%l', function(c) + return string.format('[%s%s]', string.upper(c), c) + end) + end + word_patt = '()('..word_patt..word_char..'+)' + local nonword_char = '^[^'..buffer.word_chars:gsub('(%p)', '%%%1')..']' for i = 1, #_BUFFERS do if _BUFFERS[i] == buffer or M.AUTOCOMPLETE_ALL then local text = _BUFFERS[i]:get_text() - -- Frontier pattern (%f) is too slow, so check prior char after a match. - local patt = '()('..word:gsub('(%p)', '%%%1')..word_char..'+)' - local nonword_char = '^[^'..buffer.word_chars:gsub('(%p)', '%%%1')..']' - for i, word in (not ignore_case and text or text:lower()):gmatch(patt) do + for i, word in text:gmatch(word_patt) do + -- Frontier pattern (%f) is too slow, so check prior char after a match. if (i == 1 or text:find(nonword_char, i - 1)) and not list[word] then list[#list + 1], list[word] = word, true end |