aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-18 09:47:10 +0800
committerGitHub <noreply@github.com>2024-06-18 09:47:10 +0800
commit948f2beed4ea55a9c2cce3cff894359b94fba748 (patch)
tree7e7d6f01151173a0a1ab1c78bbdd51dbf73f7221 /test
parent9d200c78a5e97720ba8a697c4cc0990fdafbc39f (diff)
downloadrneovim-948f2beed4ea55a9c2cce3cff894359b94fba748.tar.gz
rneovim-948f2beed4ea55a9c2cce3cff894359b94fba748.tar.bz2
rneovim-948f2beed4ea55a9c2cce3cff894359b94fba748.zip
fix(lua): find length of completion prefix earlier (#29384)
Do the expansion right after setting the expand context, so that the length of the completion prefix can be set, but don't do that directly in set_one_cmd_context(), as that's also called by getcmdcompltype().
Diffstat (limited to 'test')
-rw-r--r--test/functional/editor/completion_spec.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua
index a28e449f49..b42310fa81 100644
--- a/test/functional/editor/completion_spec.lua
+++ b/test/functional/editor/completion_spec.lua
@@ -812,11 +812,63 @@ describe('completion', function()
}
end)
+ it('prefix is not included in completion for cmdline mode', function()
+ feed(':lua math.a<Tab>')
+ screen:expect([[
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {100:abs}{3: acos asin atan atan2 }|
+ :lua math.abs^ |
+ ]])
+ feed('<Tab>')
+ screen:expect([[
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {3:abs }{100:acos}{3: asin atan atan2 }|
+ :lua math.acos^ |
+ ]])
+ end)
+
+ it('prefix is not included in completion for i_CTRL-X_CTRL-V #19623', function()
+ feed('ilua math.a<C-X><C-V>')
+ screen:expect([[
+ lua math.abs^ |
+ {1:~ }{12: abs }{1: }|
+ {1:~ }{4: acos }{1: }|
+ {1:~ }{4: asin }{1: }|
+ {1:~ }{4: atan }{1: }|
+ {1:~ }{4: atan2 }{1: }|
+ {1:~ }|
+ {5:-- Command-line completion (^V^N^P) }{6:match 1 of 5} |
+ ]])
+ feed('<C-V>')
+ screen:expect([[
+ lua math.acos^ |
+ {1:~ }{4: abs }{1: }|
+ {1:~ }{12: acos }{1: }|
+ {1:~ }{4: asin }{1: }|
+ {1:~ }{4: atan }{1: }|
+ {1:~ }{4: atan2 }{1: }|
+ {1:~ }|
+ {5:-- Command-line completion (^V^N^P) }{6:match 2 of 5} |
+ ]])
+ end)
+
it('provides completion from `getcompletion()`', function()
eq({ 'vim' }, fn.getcompletion('vi', 'lua'))
eq({ 'api' }, fn.getcompletion('vim.ap', 'lua'))
eq({ 'tbl_filter' }, fn.getcompletion('vim.tbl_fil', 'lua'))
eq({ 'vim' }, fn.getcompletion('print(vi', 'lua'))
+ eq({ 'abs', 'acos', 'asin', 'atan', 'atan2' }, fn.getcompletion('math.a', 'lua'))
+ eq({ 'abs', 'acos', 'asin', 'atan', 'atan2' }, fn.getcompletion('lua math.a', 'cmdline'))
-- fuzzy completion is not supported, so the result should be the same
command('set wildoptions+=fuzzy')
eq({ 'vim' }, fn.getcompletion('vi', 'lua'))