patch 9.2.0020: Wrong shortened buffer after :cd with duplicate slashes
Commit:
https://github.com/vim/vim/commit/f245e17ac70df43fd7fe650c7227bb16a4615283
Author: zeertzjq <[email protected]>
Date: Wed Feb 18 21:27:50 2026 +0000
patch 9.2.0020: Wrong shortened buffer after :cd with duplicate slashes
Problem: Wrong shortened buffer name after :cd with duplicate slashes.
Solution: Skip over multiple consecutive path separators (zeertzjq).
related: neovim/neovim#37080
closes: #19444
Signed-off-by: zeertzjq <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/fileio.c b/src/fileio.c
index 0a4ca648d..9aceaf887 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3457,7 +3457,9 @@ shorten_fname(char_u *full_path, char_u *dir_name)
#endif
{
if (vim_ispathsep(*p))
- ++p;
+ do
+ ++p;
+ while (vim_ispathsep_nocolon(*p));
#ifndef VMS // the path separator is always part of the path
else
p = NULL;
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim
index 9b74d8fdc..e95c7c2e0 100644
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -409,4 +409,15 @@ func Test_cd_symlinks()
call chdir(savedir)
endfunc
+func Test_cd_shorten_bufname_with_duplicate_slashes()
+ let savedir = getcwd()
+ call mkdir('Xexistingdir', 'R')
+ new Xexistingdir//foo/bar
+ cd Xexistingdir
+ call assert_equal('foo/bar', bufname('%'))
+
+ call chdir(savedir)
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 8fabd64ed..394a536da 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 20,
/**/
19,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vsp7X-001Ul9-MR%40256bit.org.