mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
a011f8a321
commit
35362495c9
@ -319,6 +319,9 @@ Macro/|recording| behavior
|
||||
macros and 'keymap' at the same time. This also means you can use |:imap| on
|
||||
the results of keys from 'keymap'.
|
||||
|
||||
Motion:
|
||||
The |jumplist| avoids useless/phantom jumps.
|
||||
|
||||
Normal commands:
|
||||
|Q| is the same as |gQ|
|
||||
|
||||
|
@ -1188,9 +1188,23 @@ void cleanup_jumplist(void)
|
||||
xfree(curwin->w_jumplist[from].fname);
|
||||
}
|
||||
}
|
||||
if (curwin->w_jumplistidx == curwin->w_jumplistlen)
|
||||
if (curwin->w_jumplistidx == curwin->w_jumplistlen) {
|
||||
curwin->w_jumplistidx = to;
|
||||
}
|
||||
curwin->w_jumplistlen = to;
|
||||
|
||||
// When pointer is below last jump, remove the jump if it matches the current
|
||||
// line. This avoids useless/phantom jumps. #9805
|
||||
if (curwin->w_jumplistlen
|
||||
&& curwin->w_jumplistidx == curwin->w_jumplistlen) {
|
||||
const xfmark_T *fm_last = &curwin->w_jumplist[curwin->w_jumplistlen - 1];
|
||||
if (fm_last->fmark.fnum == curbuf->b_fnum
|
||||
&& fm_last->fmark.mark.lnum == curwin->w_cursor.lnum) {
|
||||
xfree(fm_last->fname);
|
||||
curwin->w_jumplistlen--;
|
||||
curwin->w_jumplistidx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2739,8 +2739,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
|
||||
|
||||
// Initialize jump list
|
||||
const void *jump_iter = NULL;
|
||||
setpcmark();
|
||||
cleanup_jumplist();
|
||||
setpcmark();
|
||||
do {
|
||||
xfmark_T fm;
|
||||
jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm);
|
||||
|
48
test/functional/normal/jump_spec.lua
Normal file
48
test/functional/normal/jump_spec.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local funcs = helpers.funcs
|
||||
local feed = helpers.feed
|
||||
local write_file = helpers.write_file
|
||||
|
||||
describe('jumplist', function()
|
||||
local fname1 = 'Xtest-functional-normal-jump'
|
||||
local fname2 = fname1..'2'
|
||||
before_each(clear)
|
||||
after_each(function()
|
||||
os.remove(fname1)
|
||||
os.remove(fname2)
|
||||
end)
|
||||
|
||||
it('does not add a new entry on startup', function()
|
||||
eq('\n jump line col file/text\n>', funcs.execute('jumps'))
|
||||
end)
|
||||
|
||||
it('does not require two <C-O> strokes to jump back', function()
|
||||
write_file(fname1, 'first file contents')
|
||||
write_file(fname2, 'second file contents')
|
||||
|
||||
command('args '..fname1..' '..fname2)
|
||||
local buf1 = funcs.bufnr(fname1)
|
||||
local buf2 = funcs.bufnr(fname2)
|
||||
|
||||
command('next')
|
||||
feed('<C-O>')
|
||||
eq(buf1, funcs.bufnr('%'))
|
||||
|
||||
command('first')
|
||||
command('snext')
|
||||
feed('<C-O>')
|
||||
eq(buf1, funcs.bufnr('%'))
|
||||
feed('<C-I>')
|
||||
eq(buf2, funcs.bufnr('%'))
|
||||
feed('<C-O>')
|
||||
eq(buf1, funcs.bufnr('%'))
|
||||
|
||||
command('drop '..fname2)
|
||||
feed('<C-O>')
|
||||
eq(buf1, funcs.bufnr('%'))
|
||||
end)
|
||||
end)
|
@ -189,9 +189,6 @@ describe('ShaDa support code', function()
|
||||
eq(1, nvim_current_line())
|
||||
nvim_command('execute "normal! \\<C-o>"')
|
||||
eq(testfilename, funcs.bufname('%'))
|
||||
eq(1, nvim_current_line())
|
||||
nvim_command('execute "normal! \\<C-o>"')
|
||||
eq(testfilename, funcs.bufname('%'))
|
||||
eq(2, nvim_current_line())
|
||||
nvim_command('execute "normal! \\<C-o>"')
|
||||
eq(testfilename_2, funcs.bufname('%'))
|
||||
@ -199,6 +196,9 @@ describe('ShaDa support code', function()
|
||||
nvim_command('execute "normal! \\<C-o>"')
|
||||
eq(testfilename_2, funcs.bufname('%'))
|
||||
eq(2, nvim_current_line())
|
||||
nvim_command('execute "normal! \\<C-o>"')
|
||||
eq(testfilename_2, funcs.bufname('%'))
|
||||
eq(2, nvim_current_line())
|
||||
end)
|
||||
|
||||
it('is able to dump and restore change list', function()
|
||||
|
@ -912,12 +912,11 @@ describe('ShaDa jumps support code', function()
|
||||
eq('', curbufmeths.get_name())
|
||||
eq('\n'
|
||||
.. ' jump line col file/text\n'
|
||||
.. ' 6 2 0 ' .. mock_file_path .. 'c\n'
|
||||
.. ' 5 2 0 ' .. mock_file_path .. 'd\n'
|
||||
.. ' 4 3 0 ' .. mock_file_path .. 'd\n'
|
||||
.. ' 3 2 0 ' .. mock_file_path .. 'e\n'
|
||||
.. ' 2 2 0 ' .. mock_file_path .. 'f\n'
|
||||
.. ' 1 1 0 \n'
|
||||
.. ' 5 2 0 ' .. mock_file_path .. 'c\n'
|
||||
.. ' 4 2 0 ' .. mock_file_path .. 'd\n'
|
||||
.. ' 3 3 0 ' .. mock_file_path .. 'd\n'
|
||||
.. ' 2 2 0 ' .. mock_file_path .. 'e\n'
|
||||
.. ' 1 2 0 ' .. mock_file_path .. 'f\n'
|
||||
.. '>', redir_exec('jumps'))
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user