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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220314202532.8CB491C03CA%40moolenaar.net.

Raspunde prin e-mail lui