[vim/vim] cannot switch to a buffer with '%' in its name on MS-Windows (PR #20548)

4 views
Skip to first unread message

h_east

unread,
Jun 17, 2026, 1:32:02 PM (11 hours ago) Jun 17
to vim/vim, Subscribed
Problem:  On MS-Windows it is not possible to switch to a buffer by name
          with ":b" (including via command-line completion) when the
          buffer name contains '%'.
Solution: In file_pat_to_reg_pat() do not treat a backslash before '%',
          '#', ',' or a space as a path separator; these are escapes
          added by completion and must be undone, like on Unix.

fixes: #20529


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20548

Commit Summary

  • e3b6d15 cannot switch to a buffer with '%' in its name on MS-Windows

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20548@github.com>

Christian Brabandt

unread,
Jun 17, 2026, 3:00:06 PM (10 hours ago) Jun 17
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20548)

Thanks, but this breaks glob2regpat() on Windows:

echo assert_equal('^\(foo[\/]\|bar\|foobar\)$', glob2regpat('{foo\,bar,foobar}'))
^\(foo[\/]\|bar\|foobar\)$

I think the \ is considered a path separator, that's why it is converted to [\/]


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20548/c4734179403@github.com>

h_east

unread,
Jun 17, 2026, 3:23:23 PM (10 hours ago) Jun 17
to vim/vim, Subscribed
h-east left a comment (vim/vim#20548)

You're right — I'll drop the file_pat_to_reg_pat() change; it breaks the
general glob-to-regexp conversion where \ is correctly a path separator.

Root cause: on Windows % is in 'isfname', so \% is treated as a path
separator everywhere (also in rem_backslash()). Buffer completion escapes
% as \% (it's in BUFFER_ESC_CHARS), but nothing turns it back, so :b
builds a regexp with a spurious [\/] and never matches.

I think the fix belongs in completion, not file_pat_to_reg_pat(): drop %
and # from the Windows BUFFER_ESC_CHARS. :buffer has no EX_XFILE, so
they aren't expanded and don't need escaping for buffer matching. Does that
look right to you?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20548/c4734360880@github.com>

Reply all
Reply to author
Forward
0 new messages