feat(jumplist): allow opting out of removing unloaded buffers (#30419)

Problem:  Cannot opt out of removing unloaded buffers from the jumplist.
Solution: Only enable that with "clean" flag in 'jumpoptions'.
This commit is contained in:
zeertzjq
2024-09-19 18:32:50 +08:00
committed by GitHub
parent 017a054e82
commit a3f9bd7f79
9 changed files with 92 additions and 22 deletions

View File

@@ -194,7 +194,7 @@ describe("jumpoptions=stack behaves like 'tagstack'", function()
end)
end)
describe('buffer deletion', function()
describe('buffer deletion with jumpoptions+=clean', function()
local base_file = 'Xtest-functional-buffer-deletion'
local file1 = base_file .. '1'
local file2 = base_file .. '2'
@@ -227,6 +227,12 @@ describe('buffer deletion', function()
command('edit ' .. file3)
end)
after_each(function()
os.remove(file1)
os.remove(file2)
os.remove(file3)
end)
it('deletes jump list entries when the current buffer is deleted', function()
command('edit ' .. file1)
@@ -319,6 +325,44 @@ describe('buffer deletion', function()
end)
end)
describe('buffer deletion with jumpoptions-=clean', function()
local base_file = 'Xtest-functional-buffer-deletion'
local file1 = base_file .. '1'
local file2 = base_file .. '2'
local base_content = 'text'
local content1 = base_content .. '1'
local content2 = base_content .. '2'
before_each(function()
clear()
command('clearjumps')
command('set jumpoptions-=clean')
write_file(file1, content1, false, false)
write_file(file2, content2, false, false)
command('edit ' .. file1)
command('edit ' .. file2)
end)
after_each(function()
os.remove(file1)
os.remove(file2)
end)
it('Ctrl-O reopens previous buffer with :bunload or :bdelete #28968', function()
eq(file2, fn.bufname(''))
command('bunload')
eq(file1, fn.bufname(''))
feed('<C-O>')
eq(file2, fn.bufname(''))
command('bdelete')
eq(file1, fn.bufname(''))
feed('<C-O>')
eq(file2, fn.bufname(''))
end)
end)
describe('jumpoptions=view', function()
local file1 = 'Xtestfile-functional-editor-jumps'
local file2 = 'Xtestfile-functional-editor-jumps-2'

View File

@@ -13,6 +13,7 @@ if exists('s:did_load')
set laststatus=1
set listchars=eol:$
set joinspaces
set jumpoptions=
set mousemodel=extend
set nohidden nosmarttab noautoindent noautoread noruler noshowcmd
set nohlsearch noincsearch