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

This commit is contained in:
zeertzjq 2023-04-10 22:49:32 +08:00 committed by GitHub
parent bd98ef6ac6
commit 0451391ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 2 deletions

View File

@ -84,7 +84,7 @@ void clear_fmark(fmark_T *fm)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
free_fmark(*fm); free_fmark(*fm);
CLEAR_POINTER(fm); *fm = (fmark_T)INIT_FMARK;
} }
// Set named mark "c" to position "pos". // Set named mark "c" to position "pos".

View File

@ -36,7 +36,7 @@
/// Clear given fmark /// Clear given fmark
#define CLEAR_FMARK(fmarkp_) \ #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) /// Set given extended mark (regular mark + file name)
#define SET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \ #define SET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \

View File

@ -1307,6 +1307,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
.mark = cur_entry.data.filemark.mark, .mark = cur_entry.data.filemark.mark,
.fnum = (buf == NULL ? 0 : buf->b_fnum), .fnum = (buf == NULL ? 0 : buf->b_fnum),
.timestamp = cur_entry.timestamp, .timestamp = cur_entry.timestamp,
.view = INIT_FMARKV,
.additional_data = cur_entry.data.filemark.additional_data, .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, .mark = cur_entry.data.filemark.mark,
.fnum = 0, .fnum = 0,
.timestamp = cur_entry.timestamp, .timestamp = cur_entry.timestamp,
.view = INIT_FMARKV,
.additional_data = cur_entry.data.filemark.additional_data, .additional_data = cur_entry.data.filemark.additional_data,
}; };
if (cur_entry.type == kSDItemLocalMark) { if (cur_entry.type == kSDItemLocalMark) {

View File

@ -417,4 +417,48 @@ describe('named marks view', function()
| |
]]) ]])
end) 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) end)