Merge #40342 docs: misc

This commit is contained in:
Justin M. Keyes
2026-06-20 16:22:49 -04:00
committed by GitHub
5 changed files with 61 additions and 93 deletions

View File

@@ -187,9 +187,9 @@ EVENTS
• |:delmarks| now triggers the |MarkSet| autocommand with line==col==0, same
as |nvim_buf_del_mark()|
• |SessionWritePre| event emits just before |:mksession|.
• |TextPutPre| and |TextPutPost| are triggered before/after putting text.
• |TabMoved| is triggered when tabs are reordered.
• Added the |SessionWritePre| autocommand event.
HIGHLIGHTS

View File

@@ -41,6 +41,8 @@ local function check_runtime()
['lua/vim/shared.lua'] = false,
['plugin/health.vim'] = false,
['plugin/man.vim'] = false,
['plugin/nvim/net.lua'] = false,
['plugin/nvim/spellfile.lua'] = false,
['queries/help/highlights.scm'] = false,
['queries/help/injections.scm'] = false,
['scripts.vim'] = false,
@@ -176,7 +178,7 @@ local function check_watchers()
local a = vim._watch.active
local total = a.watch + a.watchdirs + a.inotify
health.info(
('filewatchers (vim._watch): %d (watch=%d, watchdirs=%d, inotify=%d)'):format(
('Filewatchers (vim._watch): %d (watch=%d, watchdirs=%d, inotify=%d)'):format(
total,
a.watch,
a.watchdirs,

View File

@@ -118,49 +118,6 @@ describe('startup', function()
command('filetype detect')
eq('filetype detection:ON plugin:OFF indent:OFF', exec_capture('filetype'))
end)
it('opens swapfile when using device path #31606', function()
t.skip(not is_os('win'), 'N/A: Windows feature')
local cwd = vim.fs.normalize(vim.uv.cwd())
local drive, path = cwd:sub(1, 1), cwd:sub(3)
local swapdir = ('%s/Xtest_swap_dir'):format(cwd)
local dos_path = ('%s/file.txt'):format(cwd)
local device_quest_path = ('//?/%s'):format(dos_path)
clear({
args = {
'--embed',
'--headless',
'--cmd',
('set directory=%s//'):format(swapdir),
'--',
device_quest_path,
},
merge = false,
})
local escaped_name = ('%s/%s.swp'):format(swapdir, dos_path:gsub('[:/]', '%%'))
eq(escaped_name, fn.swapname('%'))
command('bw!')
api.nvim_buf_set_name(0, dos_path)
eq(escaped_name, fn.swapname('%'))
command('bw!')
local device_dot_path = ('//./%s'):format(dos_path)
api.nvim_buf_set_name(0, device_dot_path)
eq(escaped_name, fn.swapname('%'))
command('bw!')
local device_unc_path = ('//?/UNC/localhost/%s$%s/file.txt'):format(drive, path)
api.nvim_buf_set_name(0, device_unc_path)
eq(('%s/%%%s.swp'):format(swapdir, device_unc_path:sub(8):gsub('/', '%%')), fn.swapname('%'))
command('bw!')
-- Volume GUID form, like \\?\Volume{d4857377-2ac4-45d8-a4cb-9b2e447fd02e}\
local guid = vim.fs.normalize(vim.trim(vim.fn.system(('mountvol %s: /L'):format(drive))))
local device_guid_path = ('%s%s/file.txt'):format(guid, path:sub(2))
api.nvim_buf_set_name(0, device_guid_path)
eq(escaped_name, fn.swapname('%'))
end)
end)
describe('startup', function()

View File

@@ -272,73 +272,39 @@ describe(':mksession', function()
it('fires SessionWritePre autocmd', function()
command('autocmd SessionWritePre * let g:session_write_pre = 1')
command('mksession ' .. session_file)
eq(1, api.nvim_eval('g:session_write_pre'))
end)
it('SessionWritePre handles editing buffer contents', function()
local tmpfile = file_prefix .. '-tmpfile-float'
command('edit ' .. tmpfile)
command("autocmd SessionWritePre * call append(0, 'foo') | write")
command('mksession ' .. session_file)
clear()
command('source ' .. session_file)
eq(2, api.nvim_buf_line_count(0))
eq({ 'foo', '' }, api.nvim_buf_get_lines(0, 0, 2, true))
eq({ 'foo', '' }, api.nvim_buf_get_lines(0, 0, -1, true))
os.remove(tmpfile)
end)
it('SessionWritePre handles switching buffers', function()
command('autocmd SessionWritePre * new')
command('mksession ' .. session_file)
clear()
command('source ' .. session_file)
-- both buffers are saved
eq(2, vim.tbl_count(api.nvim_list_bufs()))
eq(2, #api.nvim_list_bufs())
end)
it('SessionWritePre handles bwipeout', function()
it('SessionWritePre handles buffer removal', function()
-- :bdelete and :bwipeout differ for "live" Nvim but are equivalent
-- from :mksession's perspective, so one test covers both.
api.nvim_buf_set_name(0, 'foo')
command('autocmd SessionWritePre * bwipeout!')
command('mksession ' .. session_file)
-- old buffer is gone
eq('', api.nvim_buf_get_name(0))
clear()
command('source ' .. session_file)
-- gone for good
eq(
nil,
vim.iter(api.nvim_list_bufs()):find(function(b)
return api.nvim_buf_get_name(b) == 'foo'
end)
)
end)
it('SessionWritePre handles bdelete', function()
api.nvim_buf_set_name(0, 'foo')
command('autocmd SessionWritePre * bdelete!')
command('mksession ' .. session_file)
-- old buffer is gone
eq('', api.nvim_buf_get_name(0))
clear()
command('source ' .. session_file)
-- gone for good
@@ -352,12 +318,11 @@ describe(':mksession', function()
it('SessionWritePre handles splits', function()
command('autocmd SessionWritePre * split | vsplit')
command('mksession ' .. session_file)
clear()
command('source ' .. session_file)
-- contains all splits
eq(3, vim.tbl_count(api.nvim_tabpage_list_wins(0)))
eq(3, #api.nvim_tabpage_list_wins(0))
end)
end)

View File

@@ -248,13 +248,12 @@ describe('swapfile detection', function()
write_file(
testfile,
[[
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.defer_fn(function()
vim.api.nvim__redraw({ valid = false })
end, 500)
pcall(vim.cmd.edit, 'Xtest_swapredraw.lua')
]]
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.defer_fn(function()
vim.api.nvim__redraw({ valid = false })
end, 500)
pcall(vim.cmd.edit, 'Xtest_swapredraw.lua')]]
)
exec(init)
command('edit! ' .. testfile)
@@ -729,3 +728,48 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
expect_exitcode(1)
end)
end)
describe('swapfile', function()
it('when using device path #31606', function()
t.skip(not is_os('win'), 'N/A: Windows feature')
local cwd = vim.fs.normalize(vim.uv.cwd())
local drive, path = cwd:sub(1, 1), cwd:sub(3)
local swapdir = ('%s/Xtest_swap_dir'):format(cwd)
local dos_path = ('%s/file.txt'):format(cwd)
local device_quest_path = ('//?/%s'):format(dos_path)
clear({
args = {
'--embed',
'--headless',
'--cmd',
('set directory=%s//'):format(swapdir),
'--',
device_quest_path,
},
merge = false,
})
local escaped_name = ('%s/%s.swp'):format(swapdir, dos_path:gsub('[:/]', '%%'))
eq(escaped_name, fn.swapname('%'))
command('bw!')
api.nvim_buf_set_name(0, dos_path)
eq(escaped_name, fn.swapname('%'))
command('bw!')
local device_dot_path = ('//./%s'):format(dos_path)
api.nvim_buf_set_name(0, device_dot_path)
eq(escaped_name, fn.swapname('%'))
command('bw!')
local device_unc_path = ('//?/UNC/localhost/%s$%s/file.txt'):format(drive, path)
api.nvim_buf_set_name(0, device_unc_path)
eq(('%s/%%%s.swp'):format(swapdir, device_unc_path:sub(8):gsub('/', '%%')), fn.swapname('%'))
command('bw!')
-- Volume GUID form, like \\?\Volume{d4857377-2ac4-45d8-a4cb-9b2e447fd02e}\
local guid = vim.fs.normalize(vim.trim(vim.fn.system(('mountvol %s: /L'):format(drive))))
local device_guid_path = ('%s%s/file.txt'):format(guid, path:sub(2))
api.nvim_buf_set_name(0, device_guid_path)
eq(escaped_name, fn.swapname('%'))
end)
end)