diff options
author | 2020-05-26 17:13:57 -0400 | |
---|---|---|
committer | 2020-05-26 17:13:57 -0400 | |
commit | a0e14a2f9e18e324f94b6577f5bae2990b882a9d (patch) | |
tree | df82dbab26050984d61522adf725021789c9a19b | |
parent | 04b425baccdcfb5f62510ba2924d2dcd5add922a (diff) | |
download | textadept-a0e14a2f9e18e324f94b6577f5bae2990b882a9d.tar.gz textadept-a0e14a2f9e18e324f94b6577f5bae2990b882a9d.zip |
Fixed undocumented regression with word completion and case sensitivity.
This feature was inadvertently removed during a refactor.
-rw-r--r-- | modules/textadept/editing.lua | 4 | ||||
-rw-r--r-- | test/test.lua | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index c4339d63..d0331965 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -647,6 +647,7 @@ end -- Returns for the word part behind the caret a list of whole word completions -- constructed from the current buffer or all open buffers (depending on -- `M.autocomplete_all_words`). +-- If `buffer.auto_c_ignore_case` is `true`, completions are not case-sensitive. -- @see buffer.word_chars -- @see autocomplete M.autocompleters.word = function() @@ -656,7 +657,8 @@ M.autocompleters.word = function() local word_part = buffer:text_range(s, buffer.current_pos) for _, buffer in ipairs(_BUFFERS) do if buffer == _G.buffer or M.autocomplete_all_words then - buffer.search_flags = buffer.FIND_WORDSTART + buffer.FIND_MATCHCASE + buffer.search_flags = buffer.FIND_WORDSTART | + (not buffer.auto_c_ignore_case and buffer.FIND_MATCHCASE or 0) buffer:target_whole_document() while buffer:search_in_target(word_part) ~= -1 do local e = buffer:word_end_position(buffer.target_end, true) diff --git a/test/test.lua b/test/test.lua index ebdf5d74..6985bfc1 100644 --- a/test/test.lua +++ b/test/test.lua @@ -1818,6 +1818,15 @@ function test_editing_autocomplete_word() buffer:auto_c_select('foob') buffer:auto_c_complete() assert_equal(buffer:get_text(), 'foo foobar foobar') + local ignore_case = buffer.auto_c_ignore_case + buffer.auto_c_ignore_case = false + buffer:add_text(' Bar b') + textadept.editing.autocomplete('word') + assert_equal(buffer:get_text(), 'foo foobar foobar Bar b') + buffer.auto_c_ignore_case = true + textadept.editing.autocomplete('word') + assert_equal(buffer:get_text(), 'foo foobar foobar Bar Bar') + buffer.auto_c_ignore_case = ignore_case buffer.new() buffer:add_text('foob') textadept.editing.autocomplete_all_words = true |