shada: Use same merging code for jumps and changes

This commit is contained in:
ZyX
2015-08-12 21:01:45 +03:00
parent 9d8184c65a
commit 17c69258a7
3 changed files with 50 additions and 98 deletions

View File

@@ -118,28 +118,14 @@ describe('ShaDa support code', function()
nvim_command('edit ' .. testfilename)
nvim_feed('G')
nvim_feed('gg')
-- nvim_command('redir! >/tmp/jumps.last | jumps | redir END')
-- nvim_command('wshada /tmp/foo')
nvim_command('enew')
nvim_feed('gg')
nvim_command('redir => g:jumps | jumps | redir END')
local saved = nvim_eval('g:jumps')
nvim_command('qall')
reset()
nvim_command('redraw')
-- nvim_command('redir! >/tmp/jumps.init | jumps | redir END')
nvim_command('edit ' .. testfilename)
-- nvim_command('redir! >/tmp/jumps | jumps | redir END')
eq(testfilename, nvim_eval('bufname("%")'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename, nvim_eval('bufname("%")'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename, nvim_eval('bufname("%")'))
eq(2, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename_2, nvim_eval('bufname("%")'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename_2, nvim_eval('bufname("%")'))
eq(2, nvim_current_line())
nvim_command('redir => g:jumps | jumps | redir END')
eq(saved, nvim_eval('g:jumps'))
end)
it('is able to dump and restore jump list with different times (slow!)',

View File

@@ -772,12 +772,13 @@ describe('ShaDa jumps support code', function()
eq('', nvim_eval('bufname("%")'))
eq('\n'
.. ' jump line col file/text\n'
.. ' 5 2 0 /a/b/c\n'
.. ' 6 2 0 /a/b/c\n'
.. ' 5 2 0 /a/b/d\n'
.. ' 4 3 0 /a/b/d\n'
.. ' 3 2 0 /a/b/d\n'
.. ' 3 2 0 /a/b/e\n'
.. ' 2 2 0 /a/b/f\n'
.. ' 1 2 0 /a/b/e\n'
.. '> 0 1 0 ', nvim_eval('g:jumps'))
.. ' 1 1 0 \n'
.. '>', nvim_eval('g:jumps'))
end)
it('merges jumps when writing', function()
@@ -791,10 +792,10 @@ describe('ShaDa jumps support code', function()
eq(0, exc_exec('wshada ' .. shada_fname))
local jumps = {
{file='/a/b/c', line=2},
{file='/a/b/d', line=3},
{file='/a/b/d', line=2},
{file='/a/b/f', line=2},
{file='/a/b/d', line=3},
{file='/a/b/e', line=2},
{file='/a/b/f', line=2},
}
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do