fix(completion): don't include <Lua function> in -complete= (#30209)

This commit is contained in:
zeertzjq 2024-09-01 07:57:09 +08:00 committed by GitHub
parent f046c3eca6
commit bfa365a872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -415,7 +415,7 @@ char *get_user_cmd_complete(expand_T *xp, int idx)
return NULL; return NULL;
} }
char *cmd_compl = get_command_complete(idx); char *cmd_compl = get_command_complete(idx);
if (cmd_compl == NULL) { if (cmd_compl == NULL || idx == EXPAND_USER_LUA) {
return ""; return "";
} }
return cmd_compl; return cmd_compl;

View File

@ -4,7 +4,7 @@ local Screen = require('test.functional.ui.screen')
local assert_alive = n.assert_alive local assert_alive = n.assert_alive
local clear, feed = n.clear, n.feed local clear, feed = n.clear, n.feed
local eval, eq, neq = n.eval, t.eq, t.neq local eval, eq, neq, ok = n.eval, t.eq, t.neq, t.ok
local feed_command, source, expect = n.feed_command, n.source, n.expect local feed_command, source, expect = n.feed_command, n.source, n.expect
local fn = n.fn local fn = n.fn
local command = n.command local command = n.command
@ -947,6 +947,12 @@ describe('completion', function()
eq('SpecialKey', fn.getcompletion('set winhighlight=NonText:', 'cmdline')[1]) eq('SpecialKey', fn.getcompletion('set winhighlight=NonText:', 'cmdline')[1])
end) end)
it('cmdline completion for -complete does not contain spaces', function()
for _, str in ipairs(fn.getcompletion('command -complete=', 'cmdline')) do
ok(not str:find(' '), 'string without spaces', str)
end
end)
describe('from the commandline window', function() describe('from the commandline window', function()
it('is cleared after CTRL-C', function() it('is cleared after CTRL-C', function()
feed('q:') feed('q:')