aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-15 10:20:00 +0800
committerGitHub <noreply@github.com>2022-03-15 10:20:00 +0800
commitbef7552f7088ff411bd68fc236cfd7b269ad157e (patch)
tree18686d9347aabfe43937c39c7cb4dc5864c39d1f /src
parent61126fcc693c1f5aca882cfc83794f8c344df8cd (diff)
parent2ea16f73547391d014078b446d032a37c3585efa (diff)
downloadrneovim-bef7552f7088ff411bd68fc236cfd7b269ad157e.tar.gz
rneovim-bef7552f7088ff411bd68fc236cfd7b269ad157e.tar.bz2
rneovim-bef7552f7088ff411bd68fc236cfd7b269ad157e.zip
Merge pull request #17725 from zeertzjq/vim-8.2.4566
vim-patch:8.2.4566: check for existing buffer in session file may not work
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_session.c2
-rw-r--r--src/nvim/testdir/test_mksession.vim5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index ca07174543..e398c1ee64 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -365,7 +365,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
// edit that buffer, to not lose folding information (:edit resets
// folds in other buffers)
if (fprintf(fd,
- "if bufexists(\"%s\") | buffer %s | else | edit %s | endif\n"
+ "if bufexists(fnamemodify(\"%s\", \":p\")) | buffer %s | else | edit %s | endif\n"
// Fixup :terminal buffer name. #7836
"if &buftype ==# 'terminal'\n"
" silent file %s\n"
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index a8e50af510..798cb9e54f 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -219,6 +219,7 @@ func Test_mksession_one_buffer_two_windows()
let count1 = 0
let count2 = 0
let count2buf = 0
+ let bufexists = 0
for line in lines
if line =~ 'edit \f*Xtest1$'
let count1 += 1
@@ -229,10 +230,14 @@ func Test_mksession_one_buffer_two_windows()
if line =~ 'buffer \f\{-}Xtest2'
let count2buf += 1
endif
+ if line =~ 'bufexists(fnamemodify(.*, ":p")'
+ let bufexists += 1
+ endif
endfor
call assert_equal(1, count1, 'Xtest1 count')
call assert_equal(2, count2, 'Xtest2 count')
call assert_equal(2, count2buf, 'Xtest2 buffer count')
+ call assert_equal(2, bufexists)
close
bwipe!