From 668ccd97b60cc33eaf810073f3679d355c97c063 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Apr 2026 21:11:49 +0800 Subject: [PATCH] vim-patch:9.2.0416: Unix: filename completion splits at space for single-file Ex commands (#39520) Problem: SPACE_IN_FILENAME is defined on most platforms but not on Unix. As a result, set_context_for_wildcard_arg() on Unix always resets the completion pattern at white space for Ex commands that take a single file argument. Solution: Drop the SPACE_IN_FILENAME ifdef (Maxim Kim) fixes: vim/vim#18411 closes: vim/vim#20090 https://github.com/vim/vim/commit/c2bda0add96a18328299e9fe6d75925049a5146a Co-authored-by: Maxim Kim --- src/nvim/cmdexpand.c | 4 +++- test/old/testdir/test_cmdline.vim | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 620c66ba9e..8b15870b20 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1586,7 +1586,9 @@ static void set_context_for_wildcard_arg(exarg_T *eap, const char *arg, bool use in_quote = !in_quote; // An argument can contain just about everything, except // characters that end the command and white space. - } else if (c == '|' || c == '\n' || c == '"' || ascii_iswhite(c)) { + } else if (c == '|' || c == '\n' || c == '"' + || (ascii_iswhite(c) && (!(eap != NULL && (eap->argt & EX_NOSPC)) + || usefilter))) { len = 0; // avoid getting stuck when space is in 'isfname' while (*p != NUL) { c = utf_ptr2char(p); diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index aa9d66a5c3..a2ea0cc1de 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -5321,6 +5321,22 @@ func Test_rulerformat_empty() set rulerformat& endfunc +func Test_cmdline_complete_with_space() + call mkdir('Xspc', 'R') + let save_cwd = getcwd() + cd Xspc + call writefile([], 'foo bar') + call writefile([], 'baz') + call writefile([], 'bz') + + " This should expand to foo\ bar, not add 3 space separated + " files: foo baz bz + call feedkeys(":badd foo b\\\"\", 'xt') + call assert_equal('"badd foo\ bar', @:) + + call chdir(save_cwd) +endfunc + func Test_wildmode_noinsert() command! -nargs=1 -complete=custom,T MyCmd echo func T(a, c, p)