fix(cwd): :bcd completion shows non-directories #41661

Problem:
Completion for `:bcd` shows files, not just directories.

Solution:
Set the ctx properly.
This commit is contained in:
li
2026-09-05 19:56:27 +08:00
committed by GitHub
parent 48864161cd
commit 739a44753d
2 changed files with 17 additions and 0 deletions

View File

@@ -2047,6 +2047,8 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
kCallbackNone ? EXPAND_FINDFUNC : EXPAND_FILES_IN_PATH;
}
break;
case CMD_bcd:
case CMD_bchdir:
case CMD_cd:
case CMD_chdir:
case CMD_lcd:

View File

@@ -1068,6 +1068,21 @@ describe('completion', function()
eq('edit', fn.getcompletion('restart ed', 'cmdline')[1])
end)
it('cmdline completion for :*cd family shows dirs only', function()
local dir = 'Xtest-cd-compl/'
local subdir1 = dir .. 'subdir1/'
local subdir2 = dir .. 'subdir2/'
finally(function()
n.rmdir(dir)
end)
fn.mkdir(subdir1, 'p')
fn.mkdir(subdir2, 'p')
fn.writefile({ '' }, dir .. 'file')
for _, cmd in ipairs({ 'cd', 'lcd', 'tcd', 'bcd' }) do
eq({ subdir1, subdir2 }, fn.getcompletion(cmd .. ' ' .. dir, 'cmdline'))
end
end)
describe('from the commandline window', function()
it('is cleared after CTRL-C', function()
feed('q:')