1
0
forked from aniani/vim

patch 8.2.4566: check for existing buffer in session file may not work

Problem:    Check for existing buffer in session file does not work for files
            in the home directory.
Solution:   Use fnamemodify(). (James Cherti, closes #9945)  Add a test.
This commit is contained in:
James Cherti
2022-03-14 20:24:51 +00:00
committed by Bram Moolenaar
parent 6e2e2cc95b
commit 7d42840033
3 changed files with 9 additions and 2 deletions

View File

@@ -385,9 +385,9 @@ put_view(
// Note, if a buffer for that file already exists, use :badd to // Note, if a buffer for that file already exists, use :badd to
// edit that buffer, to not lose folding information (:edit resets // edit that buffer, to not lose folding information (:edit resets
// folds in other buffers) // folds in other buffers)
if (fputs("if bufexists(\"", fd) < 0 if (fputs("if bufexists(fnamemodify(\"", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL
|| fputs("\") | buffer ", fd) < 0 || fputs("\", \":p\")) | buffer ", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL
|| fputs(" | else | edit ", fd) < 0 || fputs(" | else | edit ", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL

View File

@@ -245,6 +245,7 @@ func Test_mksession_one_buffer_two_windows()
let count1 = 0 let count1 = 0
let count2 = 0 let count2 = 0
let count2buf = 0 let count2buf = 0
let bufexists = 0
for line in lines for line in lines
if line =~ 'edit \f*Xtest1$' if line =~ 'edit \f*Xtest1$'
let count1 += 1 let count1 += 1
@@ -255,10 +256,14 @@ func Test_mksession_one_buffer_two_windows()
if line =~ 'buffer \f\{-}Xtest2' if line =~ 'buffer \f\{-}Xtest2'
let count2buf += 1 let count2buf += 1
endif endif
if line =~ 'bufexists(fnamemodify(.*, ":p")'
let bufexists += 1
endif
endfor endfor
call assert_equal(1, count1, 'Xtest1 count') call assert_equal(1, count1, 'Xtest1 count')
call assert_equal(2, count2, 'Xtest2 count') call assert_equal(2, count2, 'Xtest2 count')
call assert_equal(2, count2buf, 'Xtest2 buffer count') call assert_equal(2, count2buf, 'Xtest2 buffer count')
call assert_equal(2, bufexists)
close close
bwipe! bwipe!

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4566,
/**/ /**/
4565, 4565,
/**/ /**/