diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-10-23 10:11:59 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-10-23 10:11:59 -0400 |
commit | de4cb766ca381c09fd3f938136c1932ebf008f63 (patch) | |
tree | 70aac7d6e7abc1d0cfc0e7635c6a95dbfbe48237 /src | |
parent | e38cbb93670272d0da15c60222a123b88ec55002 (diff) | |
parent | fc2bb200f75ab9650c1c35463bcc2be9008632c9 (diff) | |
download | rneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.tar.gz rneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.tar.bz2 rneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.zip |
Merge pull request #3490 from ZyX-I/fix-3472
Fix local marks saving/restoring with ShaDa
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mark.c | 29 | ||||
-rw-r--r-- | src/nvim/shada.c | 9 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index dd49b311d3..0432ec5cef 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -546,19 +546,26 @@ int check_mark(pos_T *pos) return OK; } -/* - * clrallmarks() - clear all marks in the buffer 'buf' - * - * Used mainly when trashing the entire buffer during ":e" type commands - */ -void clrallmarks(buf_T *buf) +/// Clear all marks and change list in the given buffer +/// +/// Used mainly when trashing the entire buffer during ":e" type commands. +/// +/// @param[out] buf Buffer to clear marks in. +void clrallmarks(buf_T *const buf) + FUNC_ATTR_NONNULL_ALL { - memset(&(buf->b_namedm[0]), 0, sizeof(buf->b_namedm)); - buf->b_op_start.lnum = 0; /* start/end op mark cleared */ + for (size_t i = 0; i < NMARKS; i++) { + clear_fmark(&buf->b_namedm[i]); + } + clear_fmark(&buf->b_last_cursor); + buf->b_last_cursor.mark.lnum = 1; + clear_fmark(&buf->b_last_insert); + clear_fmark(&buf->b_last_change); + buf->b_op_start.lnum = 0; // start/end op mark cleared buf->b_op_end.lnum = 0; - RESET_FMARK(&buf->b_last_cursor, ((pos_T) {1, 0, 0}), 0); // '" mark - CLEAR_FMARK(&buf->b_last_insert); // '^ mark - CLEAR_FMARK(&buf->b_last_change); // '. mark + for (int i = 0; i < buf->b_changelistlen; i++) { + clear_fmark(&buf->b_changelist[i]); + } buf->b_changelistlen = 0; } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 523f8db6f0..93a40fa736 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2433,6 +2433,15 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, msgpack_packer *const packer = msgpack_packer_new(sd_writer, &msgpack_sd_writer_write); + // Set b_last_cursor for all the buffers that have a window. + // + // It is needed to correctly save '"' mark on exit. Has a side effect of + // setting '"' mark in all windows on :wshada to the current cursor + // position (basically what :wviminfo used to do). + FOR_ALL_TAB_WINDOWS(tp, wp) { + set_last_cursor(wp); + } + FOR_ALL_BUFFERS(buf) { if (buf->b_ffname != NULL && shada_removable((char *) buf->b_ffname)) { int kh_ret; |