mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #7761 from ZyX-I/fix-7169
This commit is contained in:
commit
249bdb07dd
@ -171,6 +171,10 @@ void setpcmark(void)
|
|||||||
curwin->w_prev_pcmark = curwin->w_pcmark;
|
curwin->w_prev_pcmark = curwin->w_pcmark;
|
||||||
curwin->w_pcmark = curwin->w_cursor;
|
curwin->w_pcmark = curwin->w_cursor;
|
||||||
|
|
||||||
|
if (curwin->w_pcmark.lnum == 0) {
|
||||||
|
curwin->w_pcmark.lnum = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* If jumplist is full: remove oldest entry */
|
/* If jumplist is full: remove oldest entry */
|
||||||
if (++curwin->w_jumplistlen > JUMPLISTSIZE) {
|
if (++curwin->w_jumplistlen > JUMPLISTSIZE) {
|
||||||
curwin->w_jumplistlen = JUMPLISTSIZE;
|
curwin->w_jumplistlen = JUMPLISTSIZE;
|
||||||
|
@ -2557,6 +2557,12 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
xfmark_T fm;
|
xfmark_T fm;
|
||||||
jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm);
|
jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm);
|
||||||
|
|
||||||
|
if (fm.fmark.mark.lnum == 0) {
|
||||||
|
iemsgf("ShaDa: mark lnum zero (ji:%p, js:%p, len:%i)",
|
||||||
|
(void *)jump_iter, (void *)&curwin->w_jumplist[0],
|
||||||
|
curwin->w_jumplistlen);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const buf_T *const buf = (fm.fmark.fnum == 0
|
const buf_T *const buf = (fm.fmark.fnum == 0
|
||||||
? NULL
|
? NULL
|
||||||
: buflist_findnr(fm.fmark.fnum));
|
: buflist_findnr(fm.fmark.fnum));
|
||||||
|
@ -6,15 +6,14 @@ local write_file, merge_args = helpers.write_file, helpers.merge_args
|
|||||||
local mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
local tmpname = helpers.tmpname()
|
local tmpname = helpers.tmpname()
|
||||||
local additional_cmd = ''
|
local append_argv = nil
|
||||||
|
|
||||||
local function nvim_argv(shada_file)
|
local function nvim_argv(shada_file, embed)
|
||||||
local argv = {nvim_prog, '-u', 'NONE', '-i', shada_file or tmpname, '-N',
|
local argv = {nvim_prog, '-u', 'NONE', '-i', shada_file or tmpname, '-N',
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile',
|
'--cmd', 'set shortmess+=I background=light noswapfile',
|
||||||
'--cmd', additional_cmd,
|
embed or '--embed'}
|
||||||
'--embed'}
|
if helpers.prepend_argv or append_argv then
|
||||||
if helpers.prepend_argv then
|
return merge_args(helpers.prepend_argv, argv, append_argv)
|
||||||
return merge_args(helpers.prepend_argv, argv)
|
|
||||||
else
|
else
|
||||||
return argv
|
return argv
|
||||||
end
|
end
|
||||||
@ -26,12 +25,21 @@ local reset = function(shada_file)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local set_additional_cmd = function(s)
|
local set_additional_cmd = function(s)
|
||||||
additional_cmd = s
|
append_argv = {'--cmd', s}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function add_argv(...)
|
||||||
|
if select('#', ...) == 0 then
|
||||||
|
append_argv = nil
|
||||||
|
else
|
||||||
|
append_argv = {...}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local clear = function()
|
local clear = function()
|
||||||
|
os.execute('cp ' .. tmpname .. ' /tmp/test.shada')
|
||||||
os.remove(tmpname)
|
os.remove(tmpname)
|
||||||
set_additional_cmd('')
|
append_argv = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_shada_rw = function(fname)
|
local get_shada_rw = function(fname)
|
||||||
@ -80,7 +88,9 @@ end
|
|||||||
return {
|
return {
|
||||||
reset=reset,
|
reset=reset,
|
||||||
set_additional_cmd=set_additional_cmd,
|
set_additional_cmd=set_additional_cmd,
|
||||||
|
add_argv=add_argv,
|
||||||
clear=clear,
|
clear=clear,
|
||||||
get_shada_rw=get_shada_rw,
|
get_shada_rw=get_shada_rw,
|
||||||
read_shada_file=read_shada_file,
|
read_shada_file=read_shada_file,
|
||||||
|
nvim_argv=nvim_argv,
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ local shada_helpers = require('test.functional.shada.helpers')
|
|||||||
local reset, set_additional_cmd, clear =
|
local reset, set_additional_cmd, clear =
|
||||||
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
||||||
shada_helpers.clear
|
shada_helpers.clear
|
||||||
|
local add_argv = shada_helpers.add_argv
|
||||||
|
local nvim_argv = shada_helpers.nvim_argv
|
||||||
|
|
||||||
local nvim_current_line = function()
|
local nvim_current_line = function()
|
||||||
return curwinmeths.get_cursor()[1]
|
return curwinmeths.get_cursor()[1]
|
||||||
@ -17,8 +19,10 @@ end
|
|||||||
describe('ShaDa support code', function()
|
describe('ShaDa support code', function()
|
||||||
local testfilename = 'Xtestfile-functional-shada-marks'
|
local testfilename = 'Xtestfile-functional-shada-marks'
|
||||||
local testfilename_2 = 'Xtestfile-functional-shada-marks-2'
|
local testfilename_2 = 'Xtestfile-functional-shada-marks-2'
|
||||||
|
local non_existent_testfilename = testfilename .. '.nonexistent'
|
||||||
before_each(function()
|
before_each(function()
|
||||||
reset()
|
reset()
|
||||||
|
os.remove(non_existent_testfilename)
|
||||||
local fd = io.open(testfilename, 'w')
|
local fd = io.open(testfilename, 'w')
|
||||||
fd:write('test\n')
|
fd:write('test\n')
|
||||||
fd:write('test2\n')
|
fd:write('test2\n')
|
||||||
@ -214,4 +218,23 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('" sync 2')
|
nvim_command('" sync 2')
|
||||||
eq(2, nvim_current_line())
|
eq(2, nvim_current_line())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- -c temporary sets lnum to zero to make `+/pat` work, so calling setpcmark()
|
||||||
|
-- during -c used to add item with zero lnum to jump list.
|
||||||
|
it('does not create incorrect file for non-existent buffers when writing from -c',
|
||||||
|
function()
|
||||||
|
add_argv('--cmd', 'silent edit ' .. non_existent_testfilename, '-c', 'qall')
|
||||||
|
local argv = nvim_argv(nil, '--headless')
|
||||||
|
eq('', funcs.system(argv))
|
||||||
|
eq(0, exc_exec('rshada'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not create incorrect file for non-existent buffers opened from -c',
|
||||||
|
function()
|
||||||
|
add_argv('-c', 'silent edit ' .. non_existent_testfilename,
|
||||||
|
'-c', 'autocmd VimEnter * qall')
|
||||||
|
local argv = nvim_argv(nil, '--headless')
|
||||||
|
eq('', funcs.system(argv))
|
||||||
|
eq(0, exc_exec('rshada'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user