To: vim_dev@googlegroups.com Subject: Patch 8.2.4566 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4566 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. Files: src/session.c, src/testdir/test_mksession.vim *** ../vim-8.2.4565/src/session.c 2022-01-14 13:19:40.054831855 +0000 --- src/session.c 2022-03-14 20:04:50.110146242 +0000 *************** *** 385,393 **** // Note, if a buffer for that file already exists, use :badd to // edit that buffer, to not lose folding information (:edit resets // folds in other buffers) ! if (fputs("if bufexists(\"", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL ! || fputs("\") | buffer ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL || fputs(" | else | edit ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL --- 385,393 ---- // Note, if a buffer for that file already exists, use :badd to // edit that buffer, to not lose folding information (:edit resets // folds in other buffers) ! if (fputs("if bufexists(fnamemodify(\"", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL ! || fputs("\", \":p\")) | buffer ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL || fputs(" | else | edit ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL *** ../vim-8.2.4565/src/testdir/test_mksession.vim 2022-01-14 13:19:40.054831855 +0000 --- src/testdir/test_mksession.vim 2022-03-14 20:20:06.071773253 +0000 *************** *** 245,250 **** --- 245,251 ---- let count1 = 0 let count2 = 0 let count2buf = 0 + let bufexists = 0 for line in lines if line =~ 'edit \f*Xtest1$' let count1 += 1 *************** *** 255,264 **** --- 256,269 ---- 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! *** ../vim-8.2.4565/src/version.c 2022-03-14 19:24:41.867926390 +0000 --- src/version.c 2022-03-14 20:05:57.961950166 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4566, /**/ -- hundred-and-one symptoms of being an internet addict: 258. When you want to see your girlfriend, you surf to her homepage. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///