neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 0451391ec514eb83c7e366b80fcab21de9f8d4ed
parent bd98ef6ac6e9f059b943ddfaa6676dc48d9ea832
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon, 10 Apr 2023 22:49:32 +0800

fix(mark): properly init mark views (#22996)


Diffstat:
Msrc/nvim/mark.c | 2+-
Msrc/nvim/mark.h | 2+-
Msrc/nvim/shada.c | 2++
Mtest/functional/editor/mark_spec.lua | 44++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/nvim/mark.c b/src/nvim/mark.c @@ -84,7 +84,7 @@ void clear_fmark(fmark_T *fm) FUNC_ATTR_NONNULL_ALL { free_fmark(*fm); - CLEAR_POINTER(fm); + *fm = (fmark_T)INIT_FMARK; } // Set named mark "c" to position "pos". diff --git a/src/nvim/mark.h b/src/nvim/mark.h @@ -36,7 +36,7 @@ /// Clear given fmark #define CLEAR_FMARK(fmarkp_) \ - RESET_FMARK(fmarkp_, ((pos_T) { 0, 0, 0 }), 0, ((fmarkv_T) { 0 })) + RESET_FMARK(fmarkp_, ((pos_T) { 0, 0, 0 }), 0, ((fmarkv_T)INIT_FMARKV)) /// Set given extended mark (regular mark + file name) #define SET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \ diff --git a/src/nvim/shada.c b/src/nvim/shada.c @@ -1307,6 +1307,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) .mark = cur_entry.data.filemark.mark, .fnum = (buf == NULL ? 0 : buf->b_fnum), .timestamp = cur_entry.timestamp, + .view = INIT_FMARKV, .additional_data = cur_entry.data.filemark.additional_data, }, }; @@ -1388,6 +1389,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) .mark = cur_entry.data.filemark.mark, .fnum = 0, .timestamp = cur_entry.timestamp, + .view = INIT_FMARKV, .additional_data = cur_entry.data.filemark.additional_data, }; if (cur_entry.type == kSDItemLocalMark) { diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua @@ -417,4 +417,48 @@ describe('named marks view', function() | ]]) end) + + it('fallback to standard behavior when mark is loaded from shada', function() + local screen = Screen.new(10, 6) + screen:attach() + command('edit ' .. file1) + feed('G') + feed('mA') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + command('set shadafile=Xtestfile-functional-editor-marks-shada') + finally(function() + command('set shadafile=NONE') + os.remove('Xtestfile-functional-editor-marks-shada') + end) + command('wshada!') + command('bwipe!') + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + command('rshada!') + command('edit ' .. file1) + feed('`"') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + feed('`A') + screen:expect_unchanged() + end) end)