• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisiond768cdd50602507c491fa7afa66492e2b67de3a6 (tree)
l'heure2020-11-24 06:15:05
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.2039: viminfo is not written when creating a new file

Commit: https://github.com/vim/vim/commit/8e6be34338f13a6a625f19bcef82019c9adc65f2
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 23 22:01:26 2020 +0100

patch 8.2.2039: viminfo is not written when creating a new file
Problem: Viminfo is not written when creating a new file.
Solution: Set "b_marks_read" in the new buffer. (Christian Brabandt,
closes #7350)

Change Summary

Modification

diff -r 79eac5f2dad6 -r d768cdd50602 src/bufwrite.c
--- a/src/bufwrite.c Mon Nov 23 21:45:03 2020 +0100
+++ b/src/bufwrite.c Mon Nov 23 22:15:05 2020 +0100
@@ -2579,6 +2579,12 @@
25792579 #endif
25802580 }
25812581
2582+#ifdef FEAT_VIMINFO
2583+ // Make sure marks will be written out to the viminfo file later, even when
2584+ // the file is new.
2585+ curbuf->b_marks_read = TRUE;
2586+#endif
2587+
25822588 got_int |= prev_got_int;
25832589
25842590 return retval;
diff -r 79eac5f2dad6 -r d768cdd50602 src/testdir/test_viminfo.vim
--- a/src/testdir/test_viminfo.vim Mon Nov 23 21:45:03 2020 +0100
+++ b/src/testdir/test_viminfo.vim Mon Nov 23 22:15:05 2020 +0100
@@ -1,6 +1,8 @@
11 " Test for reading and writing .viminfo
22
33 source check.vim
4+source term_util.vim
5+source shared.vim
46
57 function Test_viminfo_read_and_write()
68 " First clear 'history', so that "hislen" is zero. Then set it again,
@@ -879,4 +881,32 @@
879881 call assert_fails('set viminfo=%10', 'E528:')
880882 endfunc
881883
884+func Test_viminfo_oldfiles_newfile()
885+ CheckRunVimInTerminal
886+
887+ let save_viminfo = &viminfo
888+ let save_viminfofile = &viminfofile
889+ set viminfo&vim
890+ let v:oldfiles = []
891+ let commands =<< trim [CODE]
892+ set viminfofile=Xviminfofile
893+ set viminfo&vim
894+ w! Xnew-file.txt
895+ qall
896+ [CODE]
897+ call writefile(commands, 'Xviminfotest')
898+ let buf = RunVimInTerminal('-S Xviminfotest', #{wait_for_ruler: 0})
899+ call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
900+
901+ let &viminfofile = 'Xviminfofile'
902+ rviminfo! Xviminfofile
903+ call assert_match('Xnew-file.txt$', v:oldfiles[0])
904+ call assert_equal(1, len(v:oldfiles))
905+ call delete('Xviminfofile')
906+ call delete('Xviminfotest')
907+ call delete('Xnew-file.txt')
908+ let &viminfo = save_viminfo
909+ let &viminfofile = save_viminfofile
910+endfunc
911+
882912 " vim: shiftwidth=2 sts=2 expandtab
diff -r 79eac5f2dad6 -r d768cdd50602 src/version.c
--- a/src/version.c Mon Nov 23 21:45:03 2020 +0100
+++ b/src/version.c Mon Nov 23 22:15:05 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2039,
755+/**/
754756 2038,
755757 /**/
756758 2037,
Afficher sur ancien navigateur de dépôt.