commit bfb70c03ff2071cd26908dc7439647bf01cec2c0
parent 625a2bfde8cd2eb9c3de1a4a9d2d062d32237c6c
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 8 Jan 2026 09:59:27 +0800
test(buffer_updates_spec): move on_detach tests to its block (#37297)
Diffstat:
3 files changed, 47 insertions(+), 45 deletions(-)
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
@@ -2605,7 +2605,7 @@ const char *did_set_langmap(optset_T *args)
langmap_set_entry(from, to);
} else {
if (to > UCHAR_MAX) {
- swmsg(true, "'langmap': mapping from %.*s to %.*s will not work properly",
+ swmsg(true, "'langmap': Mapping from %.*s to %.*s will not work properly",
utf_ptr2len(from_ptr), from_ptr, utf_ptr2len(to_ptr), to_ptr);
}
langmap_mapchar[from & 255] = (uint8_t)to;
diff --git a/test/functional/editor/langmap_spec.lua b/test/functional/editor/langmap_spec.lua
@@ -269,8 +269,8 @@ describe("'langmap'", function()
it('does not crash when mapping char < 256 to char >= 256', function()
-- Note: this warning should be removed when the pending tests above are fixed.
local wmsg = table.concat({
- "'langmap': mapping from e to ε will not work properly",
- "'langmap': mapping from ü to μ will not work properly",
+ "'langmap': Mapping from e to ε will not work properly",
+ "'langmap': Mapping from ü to μ will not work properly",
}, '\n')
-- ä ë ï ö ü ÿ < 256, β γ ε μ >= 256
command('set langmap=iw,wi,äë,ëä,ïx,xï,βγ,γβ,eε,εe,üμ,μü,ÿy,yÿ')
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
@@ -283,48 +283,6 @@ describe('lua: nvim_buf_attach on_lines', function()
eq(2, api.nvim_win_get_cursor(0)[1])
end)
- it('does not SEGFAULT when accessing window buffer info in on_detach #14998', function()
- local code = function()
- local buf = vim.api.nvim_create_buf(false, false)
-
- vim.cmd 'split'
- vim.api.nvim_win_set_buf(0, buf)
-
- vim.api.nvim_buf_attach(buf, false, {
- on_detach = function(_, buf0)
- vim.fn.tabpagebuflist()
- vim.fn.win_findbuf(buf0)
- end,
- })
- end
-
- exec_lua(code)
- command('q!')
- n.assert_alive()
-
- exec_lua(code)
- command('bd!')
- n.assert_alive()
- end)
-
- it('no invalid lnum error for closed memline in on_detach #31251', function()
- eq(vim.NIL, exec_lua('return _G.did_detach'))
- exec_lua([[
- vim.api.nvim_buf_set_lines(0, 0, -1, false, { '' })
- local bufname = 'buf2'
- local buf = vim.api.nvim_create_buf(false, true)
- vim.api.nvim_buf_set_name(buf, bufname)
- vim.bo[buf].bufhidden = 'wipe'
- vim.cmd('vertical diffsplit '..bufname)
- vim.api.nvim_buf_attach(0, false, { on_detach = function()
- vim.cmd("redraw")
- _G.did_detach = true
- end})
- vim.cmd.bdelete()
- ]])
- eq(true, exec_lua('return _G.did_detach'))
- end)
-
it('#12718 lnume', function()
api.nvim_buf_set_lines(0, 0, -1, true, { '1', '2', '3' })
exec_lua(function()
@@ -1679,6 +1637,50 @@ describe('lua: nvim_buf_attach on_bytes', function()
end)
describe('nvim_buf_attach on_detach', function()
+ it('does not SEGFAULT when accessing window buffer info #14998', function()
+ local code = function()
+ local buf = vim.api.nvim_create_buf(false, false)
+
+ vim.cmd 'split'
+ vim.api.nvim_win_set_buf(0, buf)
+
+ vim.api.nvim_buf_attach(buf, false, {
+ on_detach = function(_, buf0)
+ vim.fn.tabpagebuflist()
+ vim.fn.win_findbuf(buf0)
+ end,
+ })
+ end
+
+ exec_lua(code)
+ command('q!')
+ n.assert_alive()
+
+ exec_lua(code)
+ command('bd!')
+ n.assert_alive()
+ end)
+
+ it('no invalid lnum error for closed memline #31251', function()
+ eq(vim.NIL, exec_lua('return _G.did_detach'))
+ exec_lua(function()
+ vim.api.nvim_buf_set_lines(0, 0, -1, false, { '' })
+ local bufname = 'buf2'
+ local buf = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_buf_set_name(buf, bufname)
+ vim.bo[buf].bufhidden = 'wipe'
+ vim.cmd('vertical diffsplit ' .. bufname)
+ vim.api.nvim_buf_attach(0, false, {
+ on_detach = function()
+ vim.cmd('redraw')
+ _G.did_detach = true
+ end,
+ })
+ vim.cmd.bdelete()
+ end)
+ eq(true, exec_lua('return _G.did_detach'))
+ end)
+
it('called before buf_freeall autocommands', function()
exec_lua(function()
vim.api.nvim_create_autocmd({ 'BufUnload', 'BufDelete', 'BufWipeout' }, {