]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0020: Wrong shortened buffer after :cd with duplicate slashes v9.2.0020
authorzeertzjq <zeertzjq@outlook.com>
Wed, 18 Feb 2026 21:27:50 +0000 (21:27 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 18 Feb 2026 21:27:50 +0000 (21:27 +0000)
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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/fileio.c
src/testdir/test_cd.vim
src/version.c

index 0a4ca648d8aea3a9aa41d956a289f10f834a66ec..9aceaf887637b9db328f18993697a1c21a6bd4c1 100644 (file)
@@ -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;
index 9b74d8fdcad701239d852795483bec1496a04fcb..e95c7c2e0e3c861d529b2627b2e1d2c2aa076b59 100644 (file)
@@ -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
index 8fabd64ed3d354663adda26efe0467519f7758b2..394a536da0b0577f7df6c2a4f9aa66536f550edb 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    20,
 /**/
     19,
 /**/