diff options
author | vE5li <ve5li@tuta.io> | 2024-01-29 04:08:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-28 19:08:51 -0800 |
commit | af6537bc66e2ea506b9640c34720ef85d4704be6 (patch) | |
tree | 4ffa528dff7c9aafeaa8157690a89e3bf1adc90a /test | |
parent | eee52d3427e2c97c0e9a9347bafdd55d49830ec7 (diff) | |
download | rneovim-af6537bc66e2ea506b9640c34720ef85d4704be6.tar.gz rneovim-af6537bc66e2ea506b9640c34720ef85d4704be6.tar.bz2 rneovim-af6537bc66e2ea506b9640c34720ef85d4704be6.zip |
fix(jumplist): Ctrl+o, Ctrl+i weird behavior when deleting buffers #25461
Problem:
- Navigation is not always symmetric: pressing Ctrl+o n times followed
by Ctrl+i n times does not always gets me back to where I started.
- Invalid buffers are not skipped by Ctrl+i/o, I have to press Ctrl+i/o
multiple times to get to the next/previous buffer.
Solution:
- Remove all entries of a buffer from the jump list when deleting it.
- Don't add a new entry to the jump list if the next buffer to be
displayed is already in the jump list.
Closes #25365
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/editor/jump_spec.lua | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua index 717284b7d1..fe03d82164 100644 --- a/test/functional/editor/jump_spec.lua +++ b/test/functional/editor/jump_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command +local dedent = helpers.dedent local eq = helpers.eq local fn = helpers.fn local feed = helpers.feed @@ -192,6 +193,131 @@ describe("jumpoptions=stack behaves like 'tagstack'", function() end) end) +describe('buffer deletion', function() + local base_file = 'Xtest-functional-buffer-deletion' + local file1 = base_file .. '1' + local file2 = base_file .. '2' + local file3 = base_file .. '3' + local base_content = 'text' + local content1 = base_content .. '1' + local content2 = base_content .. '2' + local content3 = base_content .. '3' + + local function format_jumplist(input) + return dedent(input) + :gsub('%{file1%}', file1) + :gsub('%{file2%}', file2) + :gsub('%{file3%}', file3) + :gsub('%{content1%}', content1) + :gsub('%{content2%}', content2) + :gsub('%{content3%}', content3) + end + + before_each(function() + clear() + command('clearjumps') + + write_file(file1, content1, false, false) + write_file(file2, content2, false, false) + write_file(file3, content3, false, false) + + command('edit ' .. file1) + command('edit ' .. file2) + command('edit ' .. file3) + end) + + it('deletes jump list entries when the current buffer is deleted', function() + command('edit ' .. file1) + + eq( + format_jumplist([[ + jump line col file/text + 3 1 0 {content1} + 2 1 0 {file2} + 1 1 0 {file3} + >]]), + exec_capture('jumps') + ) + + command('bwipeout') + + eq( + format_jumplist([[ + jump line col file/text + 1 1 0 {file2} + > 0 1 0 {content3}]]), + exec_capture('jumps') + ) + end) + + it('deletes jump list entries when another buffer is deleted', function() + eq( + format_jumplist([[ + jump line col file/text + 2 1 0 {file1} + 1 1 0 {file2} + >]]), + exec_capture('jumps') + ) + + command('bwipeout ' .. file2) + + eq( + format_jumplist([[ + jump line col file/text + 1 1 0 {file1} + >]]), + exec_capture('jumps') + ) + end) + + it('sets the correct jump index when the current buffer is deleted', function() + feed('<C-O>') + + eq( + format_jumplist([[ + jump line col file/text + 1 1 0 {file1} + > 0 1 0 {content2} + 1 1 0 {file3}]]), + exec_capture('jumps') + ) + + command('bw') + + eq( + format_jumplist([[ + jump line col file/text + 1 1 0 {file1} + > 0 1 0 {content3}]]), + exec_capture('jumps') + ) + end) + + it('sets the correct jump index when the another buffer is deleted', function() + feed('<C-O>') + + eq( + format_jumplist([[ + jump line col file/text + 1 1 0 {file1} + > 0 1 0 {content2} + 1 1 0 {file3}]]), + exec_capture('jumps') + ) + + command('bwipeout ' .. file1) + + eq( + format_jumplist([[ + jump line col file/text + > 0 1 0 {content2} + 1 1 0 {file3}]]), + exec_capture('jumps') + ) + end) +end) + describe('jumpoptions=view', function() local file1 = 'Xtestfile-functional-editor-jumps' local file2 = 'Xtestfile-functional-editor-jumps-2' |