mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 21:02:11 +00:00
vim-patch:9.2.0020: Wrong shortened buffer after :cd with duplicate slashes (#37955)
Problem: Wrong shortened buffer name after :cd with duplicate slashes.
Solution: Skip over multiple consecutive path separators (zeertzjq).
related: neovim/neovim#37080
closes: vim/vim#19444
f245e17ac7
N/A patches:
vim-patch:9.0.1859: heap-use-after-free in bt_normal()
vim-patch:9.2.0022: bt_quickfix() is slow
This commit is contained in:
@@ -2121,7 +2121,10 @@ char *path_shorten_fname(char *full_path, char *dir_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p + 1;
|
||||
do {
|
||||
p++;
|
||||
} while (vim_ispathsep_nocolon(*p));
|
||||
return p;
|
||||
}
|
||||
|
||||
/// Invoke expand_wildcards() for one pattern
|
||||
|
||||
@@ -414,4 +414,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
|
||||
|
||||
@@ -299,6 +299,11 @@ describe('path.c', function()
|
||||
local full = to_cstr('some/very/long/directory/file.txt')
|
||||
local dir = to_cstr('some/very/long')
|
||||
eq('directory/file.txt', (ffi.string(cimp.path_shorten_fname(full, dir))))
|
||||
-- Also works with duplicate slashes. #37080
|
||||
full = to_cstr('some/very/long//directory/file.txt')
|
||||
eq('directory/file.txt', (ffi.string(cimp.path_shorten_fname(full, dir))))
|
||||
full = to_cstr('some/very/long///directory/file.txt')
|
||||
eq('directory/file.txt', (ffi.string(cimp.path_shorten_fname(full, dir))))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user