Mercurial > vim
diff src/ex_cmds.c @ 9414:1003973c99df v7.4.1988
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 3 17:47:26 2016 +0200
patch 7.4.1988
Problem: When updating viminfo with file marks there is no time order.
Solution: Remember the time when a buffer was last used, store marks for
the most recently used buffers.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jul 2016 18:00:05 +0200 |
parents | 80333fcbaddf |
children | 38e2fc4ee4ef |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2148,10 +2148,11 @@ viminfo_filename(char_u *file) static void do_viminfo(FILE *fp_in, FILE *fp_out, int flags) { - int count = 0; int eof = FALSE; vir_T vir; int merge = FALSE; + int do_copy_marks = FALSE; + garray_T buflist; if ((vir.vir_line = alloc(LSIZE)) == NULL) return; @@ -2183,7 +2184,11 @@ do_viminfo(FILE *fp_in, FILE *fp_out, in while (!(eof = viminfo_readline(&vir)) && vir.vir_line[0] != '>') ; - } + + do_copy_marks = (flags & + (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT)); + } + if (fp_out != NULL) { /* Write the info: */ @@ -2209,11 +2214,18 @@ do_viminfo(FILE *fp_in, FILE *fp_out, in finish_viminfo_marks(); write_viminfo_bufferlist(fp_out); write_viminfo_barlines(&vir, fp_out); - count = write_viminfo_marks(fp_out); - } - if (fp_in != NULL - && (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT))) - copy_viminfo_marks(&vir, fp_out, count, eof, flags); + + if (do_copy_marks) + ga_init2(&buflist, sizeof(buf_T *), 50); + write_viminfo_marks(fp_out, do_copy_marks ? &buflist : NULL); + } + + if (do_copy_marks) + { + copy_viminfo_marks(&vir, fp_out, &buflist, eof, flags); + if (fp_out != NULL) + ga_clear(&buflist); + } vim_free(vir.vir_line); #ifdef FEAT_MBYTE @@ -4287,6 +4299,10 @@ do_ecmd( msg_scrolled_ign = FALSE; } +#ifdef FEAT_VIMINFO + curbuf->b_last_used = vim_time(); +#endif + if (command != NULL) do_cmdline(command, NULL, NULL, DOCMD_VERBOSE);