From 5260243c48f83bbf82431e3b85cc4a868ffbecf1 Mon Sep 17 00:00:00 2001 From: Guilherme Soares Date: Tue, 12 Nov 2024 18:12:42 +0000 Subject: [PATCH] test(treesitter): update inspect_tree tests To prevent #30986 and #31198 regression update inspect_tree tests --- .../treesitter/inspect_tree_spec.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/functional/treesitter/inspect_tree_spec.lua b/test/functional/treesitter/inspect_tree_spec.lua index 1f7d15cc96..0a55b4e871 100644 --- a/test/functional/treesitter/inspect_tree_spec.lua +++ b/test/functional/treesitter/inspect_tree_spec.lua @@ -127,7 +127,7 @@ describe('vim.treesitter.inspect_tree', function() -- setup two windows for the source buffer exec_lua(function() _G.source_win = vim.api.nvim_get_current_win() - vim.api.nvim_open_win(0, false, { + _G.source_win_copy = vim.api.nvim_open_win(0, false, { win = 0, split = 'left', }) @@ -148,12 +148,19 @@ describe('vim.treesitter.inspect_tree', function() }) end) - -- close original source window - exec_lua('vim.api.nvim_win_close(source_win, false)') + -- close original source window without closing tree views + exec_lua('vim.api.nvim_set_current_win(source_win)') + feed(':q') + eq('', n.api.nvim_get_vvar('errmsg')) + eq(true, exec_lua('return vim.api.nvim_win_is_valid(tree_win)')) + eq(true, exec_lua('return vim.api.nvim_win_is_valid(tree_win_copy_1)')) + eq(true, exec_lua('return vim.api.nvim_win_is_valid(tree_win_copy_2)')) -- navigates correctly to the remaining source buffer window + exec_lua('vim.api.nvim_set_current_win(tree_win)') feed('') eq('', n.api.nvim_get_vvar('errmsg')) + eq(true, exec_lua('return vim.api.nvim_get_current_win() == source_win_copy')) -- close original tree window exec_lua(function() @@ -164,10 +171,11 @@ describe('vim.treesitter.inspect_tree', function() -- navigates correctly to the remaining source buffer window feed('') eq('', n.api.nvim_get_vvar('errmsg')) + eq(true, exec_lua('return vim.api.nvim_get_current_win() == source_win_copy')) -- close source buffer window and all remaining tree windows - t.pcall_err(exec_lua, 'vim.api.nvim_win_close(0, false)') - + feed(':q') + t.eq('E162: No write since last change for buffer "[No Name]"', n.api.nvim_get_vvar('errmsg')) eq(false, exec_lua('return vim.api.nvim_win_is_valid(tree_win_copy_1)')) eq(false, exec_lua('return vim.api.nvim_win_is_valid(tree_win_copy_2)')) end)