aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake.deps/deps.txt4
-rw-r--r--runtime/autoload/provider/pythonx.vim9
-rw-r--r--runtime/doc/lua.txt23
-rw-r--r--runtime/lua/vim/_editor.lua19
-rw-r--r--runtime/lua/vim/_meta/builtin.lua6
-rw-r--r--runtime/lua/vim/_meta/json.lua3
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua4
-rw-r--r--src/nvim/arglist.c20
-rw-r--r--src/nvim/autocmd.c3
-rw-r--r--src/nvim/buffer.c30
-rw-r--r--src/nvim/lua/stdlib.c3
-rw-r--r--src/nvim/main.c3
-rw-r--r--src/nvim/tui/tui.c3
-rw-r--r--test/functional/api/vim_spec.lua3
-rw-r--r--test/functional/lua/vim_spec.lua2
-rw-r--r--test/functional/terminal/tui_spec.lua66
-rw-r--r--test/functional/treesitter/highlight_spec.lua64
-rw-r--r--test/functional/ui/float_spec.lua169
-rw-r--r--test/old/testdir/test_autocmd.vim15
19 files changed, 400 insertions, 49 deletions
diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt
index 4c23803560..9ffc72b404 100644
--- a/cmake.deps/deps.txt
+++ b/cmake.deps/deps.txt
@@ -4,8 +4,8 @@ LIBUV_SHA256 7aa66be3413ae10605e1f5c9ae934504ffe317ef68ea16fdaa83e23905c681bd
MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/c-6.0.0/msgpack-c-6.0.0.tar.gz
MSGPACK_SHA256 3654f5e2c652dc52e0a993e270bb57d5702b262703f03771c152bba51602aeba
-LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/d1a2fef8a8f53b0055ee041f7f63d83a27444ffa.tar.gz
-LUAJIT_SHA256 7d4dd85cbf224c70f2014203903202a90f3cfe7b1c6e7b1b36f8ae472dfc7fba
+LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/97c75843c642d304a81f20576a8e3dda9097e8b8.tar.gz
+LUAJIT_SHA256 84636e20b228741505f84cd450b7cd9a0cbefc106b7400a0755219211fccbe7d
LUA_URL https://www.lua.org/ftp/lua-5.1.5.tar.gz
LUA_SHA256 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 6211b457d6..db6acf4526 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -26,7 +26,7 @@ endfunction
function! s:get_python_candidates(major_version) abort
return {
- \ 3: ['python3', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python']
+ \ 3: ['python3', 'python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python']
\ }[a:major_version]
endfunction
@@ -61,12 +61,11 @@ endfunction
" Returns array: [prog_exitcode, prog_version]
function! s:import_module(prog, module) abort
- let prog_version = system([a:prog, '-c' , printf(
- \ 'import sys; ' .
+ let prog_version = system([a:prog, '-W', 'ignore', '-c', printf(
+ \ 'import sys, importlib; ' .
\ 'sys.path = [p for p in sys.path if p != ""]; ' .
\ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
- \ 'import pkgutil; ' .
- \ 'exit(2*int(pkgutil.get_loader("%s") is None))',
+ \ 'sys.exit(2 * int(importlib.util.find_spec("%s") is None))',
\ a:module)])
return [v:shell_error, prog_version]
endfunction
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index efba10b86f..ddf11fd966 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -956,12 +956,12 @@ vim.rpcrequest({channel}, {method}, {args}, {...}) *vim.rpcrequest()*
• {args} any[]|nil
• {...} any|nil
-vim.schedule({callback}) *vim.schedule()*
- Schedules {callback} to be invoked soon by the main event-loop. Useful to
- avoid |textlock| or other temporary restrictions.
+vim.schedule({fn}) *vim.schedule()*
+ Schedules {fn} to be invoked soon by the main event-loop. Useful to avoid
+ |textlock| or other temporary restrictions.
Parameters: ~
- • {callback} fun()
+ • {fn} (function)
vim.str_byteindex({str}, {index}, {use_utf16}) *vim.str_byteindex()*
Convert UTF-32 or UTF-16 {index} to byte index. If {use_utf16} is not
@@ -1714,11 +1714,20 @@ vim.region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive})
`endcol` is exclusive, and whole lines are returned as
`{startcol,endcol} = {0,-1}`.
-vim.schedule_wrap({cb}) *vim.schedule_wrap()*
- Defers callback `cb` until the Nvim API is safe to call.
+vim.schedule_wrap({fn}) *vim.schedule_wrap()*
+ Returns a function which calls {fn} via |vim.schedule()|.
+
+ The returned function passes all arguments to {fn}.
+
+ Example: >lua
+ function notify_readable(_err, readable)
+ vim.notify("readable? " .. tostring(readable))
+ end
+ vim.uv.fs_access(vim.fn.stdpath("config"), "R", vim.schedule_wrap(notify_readable))
+<
Parameters: ~
- • {cb} (function)
+ • {fn} (function)
Return: ~
(function)
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 8322777633..e4a2dadb09 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -316,18 +316,29 @@ do
end
end
---- Defers callback `cb` until the Nvim API is safe to call.
+--- Returns a function which calls {fn} via |vim.schedule()|.
+---
+--- The returned function passes all arguments to {fn}.
+---
+--- Example:
+---
+--- ```lua
+--- function notify_readable(_err, readable)
+--- vim.notify("readable? " .. tostring(readable))
+--- end
+--- vim.uv.fs_access(vim.fn.stdpath("config"), "R", vim.schedule_wrap(notify_readable))
+--- ```
---
---@see |lua-loop-callbacks|
---@see |vim.schedule()|
---@see |vim.in_fast_event()|
----@param cb function
+---@param fn function
---@return function
-function vim.schedule_wrap(cb)
+function vim.schedule_wrap(fn)
return function(...)
local args = vim.F.pack_len(...)
vim.schedule(function()
- cb(vim.F.unpack_len(args))
+ fn(vim.F.unpack_len(args))
end)
end
end
diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua
index 0a6dd3e151..92c23f7764 100644
--- a/runtime/lua/vim/_meta/builtin.lua
+++ b/runtime/lua/vim/_meta/builtin.lua
@@ -194,10 +194,10 @@ function vim.str_utfindex(str, index) end
--- @return string|nil Converted string if conversion succeeds, `nil` otherwise.
function vim.iconv(str, from, to, opts) end
---- Schedules {callback} to be invoked soon by the main event-loop. Useful
+--- Schedules {fn} to be invoked soon by the main event-loop. Useful
--- to avoid |textlock| or other temporary restrictions.
---- @param callback fun()
-function vim.schedule(callback) end
+--- @param fn function
+function vim.schedule(fn) end
--- Wait for {time} in milliseconds until {callback} returns `true`.
---
diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua
index edf905c7c6..e010086615 100644
--- a/runtime/lua/vim/_meta/json.lua
+++ b/runtime/lua/vim/_meta/json.lua
@@ -1,5 +1,8 @@
---@meta
+---@nodoc
+vim.json = {}
+
-- luacheck: no unused args
---@defgroup vim.json
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index b2c4e9167d..670f2797b7 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -650,8 +650,8 @@ function LanguageTree:included_regions()
return self._regions
end
- if not self._has_regions or next(self._trees) == nil then
- -- treesitter.c will default empty ranges to { -1, -1, -1, -1, -1, -1}
+ if not self._has_regions then
+ -- treesitter.c will default empty ranges to { -1, -1, -1, -1, -1, -1} (the full range)
return { {} }
end
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c
index 74348052b0..9c2b3ba6d8 100644
--- a/src/nvim/arglist.c
+++ b/src/nvim/arglist.c
@@ -857,12 +857,17 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall)
while (true) {
win_T *wpnext = NULL;
tabpage_T *tpnext = curtab->tp_next;
- for (win_T *wp = firstwin; wp != NULL; wp = wpnext) {
+ // Try to close floating windows first
+ for (win_T *wp = lastwin->w_floating ? lastwin : firstwin; wp != NULL; wp = wpnext) {
int i;
- wpnext = wp->w_next;
+ wpnext = wp->w_floating
+ ? wp->w_prev->w_floating ? wp->w_prev : firstwin
+ : (wp->w_next == NULL || wp->w_next->w_floating) ? NULL : wp->w_next;
buf_T *buf = wp->w_buffer;
if (buf->b_ffname == NULL
- || (!aall->keep_tabs && (buf->b_nwindows > 1 || wp->w_width != Columns))) {
+ || (!aall->keep_tabs
+ && (buf->b_nwindows > 1 || wp->w_width != Columns
+ || (wp->w_floating && !is_aucmd_win(wp))))) {
i = aall->opened_len;
} else {
// check if the buffer in this window is in the arglist
@@ -917,7 +922,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall)
(void)autowrite(buf, false);
// Check if autocommands removed the window.
if (!win_valid(wp) || !bufref_valid(&bufref)) {
- wpnext = firstwin; // Start all over...
+ wpnext = lastwin->w_floating ? lastwin : firstwin; // Start all over...
continue;
}
}
@@ -930,7 +935,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall)
// check if autocommands removed the next window
if (!win_valid(wpnext)) {
// start all over...
- wpnext = firstwin;
+ wpnext = lastwin->w_floating ? lastwin : firstwin;
}
}
}
@@ -977,6 +982,8 @@ static void arg_all_open_windows(arg_all_state_T *aall, int count)
if (aall->keep_tabs) {
aall->new_curwin = wp;
aall->new_curtab = curtab;
+ } else if (wp->w_floating) {
+ break;
} else if (wp->w_frame->fr_parent != curwin->w_frame->fr_parent) {
emsg(_(e_window_layout_changed_unexpectedly));
i = count;
@@ -1098,7 +1105,8 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
autocmd_no_leave++;
last_curwin = curwin;
last_curtab = curtab;
- win_enter(lastwin, false);
+ // lastwin may be aucmd_win
+ win_enter(lastwin_nofloating(), false);
// Open up to "count" windows.
arg_all_open_windows(&aall, count);
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 3fa20f4e48..ff0c2f063f 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1341,7 +1341,6 @@ void aucmd_restbuf(aco_save_T *aco)
if (aco->use_aucmd_win_idx >= 0) {
win_T *awp = aucmd_win[aco->use_aucmd_win_idx].auc_win;
- curbuf->b_nwindows--;
// Find "awp", it can't be closed, but it may be in another tab page.
// Do not trigger autocommands here.
block_autocmds();
@@ -1357,7 +1356,7 @@ void aucmd_restbuf(aco_save_T *aco)
}
}
win_found:
- ;
+ curbuf->b_nwindows--;
const bool save_stop_insert_mode = stop_insert_mode;
// May need to stop Insert mode if we were in a prompt buffer.
leaving_window(curwin);
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d2a5eab0a5..68cef67c8a 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3616,21 +3616,28 @@ void ex_buffer_all(exarg_T *eap)
}
while (true) {
tpnext = curtab->tp_next;
- for (wp = firstwin; wp != NULL; wp = wpnext) {
- wpnext = wp->w_next;
+ // Try to close floating windows first
+ for (wp = lastwin->w_floating ? lastwin : firstwin; wp != NULL; wp = wpnext) {
+ wpnext = wp->w_floating
+ ? wp->w_prev->w_floating ? wp->w_prev : firstwin
+ : (wp->w_next == NULL || wp->w_next->w_floating) ? NULL : wp->w_next;
if ((wp->w_buffer->b_nwindows > 1
+ || wp->w_floating
|| ((cmdmod.cmod_split & WSP_VERT)
? wp->w_height + wp->w_hsep_height + wp->w_status_height < Rows - p_ch
- tabline_height() - global_stl_height()
: wp->w_width != Columns)
|| (had_tab > 0 && wp != firstwin))
&& !ONE_WINDOW
- && !(wp->w_closing
- || wp->w_buffer->b_locked > 0)) {
- win_close(wp, false, false);
- wpnext = firstwin; // just in case an autocommand does
- // something strange with windows
- tpnext = first_tabpage; // start all over...
+ && !(wp->w_closing || wp->w_buffer->b_locked > 0)
+ && !is_aucmd_win(wp)) {
+ if (win_close(wp, false, false) == FAIL) {
+ break;
+ }
+ // Just in case an autocommand does something strange with
+ // windows: start all over...
+ wpnext = lastwin->w_floating ? lastwin : firstwin;
+ tpnext = first_tabpage;
open_wins = 0;
} else {
open_wins++;
@@ -3650,7 +3657,8 @@ void ex_buffer_all(exarg_T *eap)
//
// Don't execute Win/Buf Enter/Leave autocommands here.
autocmd_no_enter++;
- win_enter(lastwin, false);
+ // lastwin may be aucmd_win
+ win_enter(lastwin_nofloating(), false);
autocmd_no_leave++;
for (buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) {
// Check if this buffer needs a window
@@ -3668,7 +3676,7 @@ void ex_buffer_all(exarg_T *eap)
} else {
// Check if this buffer already has a window
for (wp = firstwin; wp != NULL; wp = wp->w_next) {
- if (wp->w_buffer == buf) {
+ if (!wp->w_floating && wp->w_buffer == buf) {
break;
}
}
@@ -3742,7 +3750,7 @@ void ex_buffer_all(exarg_T *eap)
// Close superfluous windows.
for (wp = lastwin; open_wins > count;) {
r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer)
- || autowrite(wp->w_buffer, false) == OK);
+ || autowrite(wp->w_buffer, false) == OK) && !is_aucmd_win(wp);
if (!win_valid(wp)) {
// BufWrite Autocommands made the window invalid, start over
wp = lastwin;
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 4f9677650f..8f1b5c7b86 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -359,6 +359,9 @@ int nlua_setvar(lua_State *lstate)
Error err = ERROR_INIT;
dictitem_T *di = dict_check_writable(dict, key, del, &err);
if (ERROR_SET(&err)) {
+ nlua_push_errstr(lstate, "%s", err.msg);
+ api_clear_error(&err);
+ lua_error(lstate);
return 0;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index d9ca82784f..0bb69d000b 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -659,6 +659,9 @@ void os_exit(int r)
if (ui_client_channel_id) {
ui_client_stop();
+ if (r == 0) {
+ r = ui_client_exit_status;
+ }
} else {
ui_flush();
ui_call_stop();
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 4097b770c9..db15cdb053 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -386,6 +386,9 @@ static void terminfo_stop(TUIData *tui)
unibi_out_ext(tui, tui->unibi_ext.disable_extended_keys);
// May restore old title before exiting alternate screen.
tui_set_title(tui, (String)STRING_INIT);
+ if (ui_client_exit_status == 0) {
+ ui_client_exit_status = tui->seen_error_exit;
+ }
// if nvim exited with nonzero status, without indicated this was an
// intentional exit (like `:1cquit`), it likely was an internal failure.
// Don't clobber the stderr error message in this case.
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index f734bfb0c0..fcf3eae5ec 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1353,6 +1353,9 @@ describe('API', function()
-- Set readonly v: var.
eq('Key is read-only: count',
pcall_err(request, 'nvim_set_vvar', 'count', 42))
+ -- Set non-existent v: var.
+ eq('Dictionary is locked',
+ pcall_err(request, 'nvim_set_vvar', 'nosuchvar', 42))
-- Set writable v: var.
meths.set_vvar('errmsg', 'set by API')
eq('set by API', meths.get_vvar('errmsg'))
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 1dfb9a5e10..cf80478b08 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -1491,6 +1491,8 @@ describe('lua stdlib', function()
eq(NIL, funcs.luaeval "vim.v.null")
matches([[attempt to index .* nil value]],
pcall_err(exec_lua, 'return vim.v[0].progpath'))
+ eq('Key is read-only: count', pcall_err(exec_lua, 'vim.v.count = 42'))
+ eq('Dictionary is locked', pcall_err(exec_lua, 'vim.v.nosuchvar = 42'))
end)
it('vim.bo', function()
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 2d4613dda4..f8d2c01771 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1720,7 +1720,15 @@ describe('TUI', function()
it('no assert failure on deadly signal #21896', function()
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
- screen:expect({any = '%[Process exited 1%]'})
+ screen:expect{grid=[[
+ Vim: Caught deadly signal 'SIGTERM' |
+ |
+ |
+ [Process exited 1]{1: } |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]]}
end)
it('no stack-use-after-scope with cursor color #22432', function()
@@ -2743,7 +2751,15 @@ describe("TUI as a client", function()
-- No heap-use-after-free when receiving UI events after deadly signal #22184
server:request('nvim_input', ('a'):rep(1000))
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
- screen:expect({any = '%[Process exited 1%]'})
+ screen:expect{grid=[[
+ Vim: Caught deadly signal 'SIGTERM' |
+ |
+ |
+ [Process exited 1]{1: } |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]]}
eq(0, meths.get_vvar('shell_error'))
-- exits on input eof #22244
@@ -2771,7 +2787,7 @@ describe("TUI as a client", function()
]])
end)
- it("exits when server quits", function()
+ local function test_remote_tui_quit(status)
local server_super = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true)
@@ -2780,6 +2796,15 @@ describe("TUI as a client", function()
local screen_server = thelpers.screen_setup(0,
string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
nvim_prog, server_pipe, nvim_set))
+ screen_server:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
feed_data("iHello, World")
screen_server:expect{grid=[[
@@ -2819,13 +2844,40 @@ describe("TUI as a client", function()
-- quitting the server
set_session(server_super)
- feed_data(":q!\n")
- screen_server:expect({any="Process exited 0"})
-
+ feed_data(status and ':' .. status .. 'cquit!\n' or ":quit!\n")
+ status = status and status or 0
+ screen_server:expect{grid=[[
+ |
+ [Process exited ]] .. status .. [[]{1: }{MATCH:%s+}|
+ |
+ |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]]}
-- assert that client has exited
- screen_client:expect({any="Process exited 0"})
+ screen_client:expect{grid=[[
+ |
+ [Process exited ]] .. status .. [[]{1: }{MATCH:%s+}|
+ |
+ |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+
server_super:close()
client_super:close()
+ end
+
+ describe("exits when server quits", function()
+ it("with :quit", function()
+ test_remote_tui_quit()
+ end)
+
+ it("with :cquit", function()
+ test_remote_tui_quit(42)
+ end)
end)
end)
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 0aa0cdd6d6..e037c9e215 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -838,3 +838,67 @@ describe('treesitter highlighting (help)', function()
end)
end)
+
+describe('treesitter highlighting (nested injections)', function()
+ local screen
+
+ before_each(function()
+ screen = Screen.new(80, 7)
+ screen:attach()
+ screen:set_default_attr_ids {
+ [1] = {foreground = Screen.colors.SlateBlue};
+ [2] = {bold = true, foreground = Screen.colors.Brown};
+ [3] = {foreground = Screen.colors.Cyan4};
+ [4] = {foreground = Screen.colors.Fuchsia};
+ }
+ end)
+
+ it("correctly redraws nested injections (GitHub #25252)", function()
+ insert[=[
+function foo() print("Lua!") end
+
+local lorem = {
+ ipsum = {},
+ bar = {},
+}
+vim.cmd([[
+ augroup RustLSP
+ autocmd CursorHold silent! lua vim.lsp.buf.document_highlight()
+ augroup END
+]])
+ ]=]
+
+ exec_lua [[
+ vim.opt.scrolloff = 0
+ vim.bo.filetype = 'lua'
+ vim.treesitter.start()
+ ]]
+
+ -- invalidate the language tree
+ feed("ggi--[[<ESC>04x")
+
+ screen:expect{grid=[[
+ {2:^function} {3:foo}{1:()} {1:print(}{4:"Lua!"}{1:)} {2:end} |
+ |
+ {2:local} {3:lorem} {2:=} {1:{} |
+ {3:ipsum} {2:=} {1:{},} |
+ {3:bar} {2:=} {1:{},} |
+ {1:}} |
+ |
+ ]]}
+
+ -- spam newline insert/delete to invalidate Lua > Vim > Lua region
+ feed("3jo<ESC>ddko<ESC>ddko<ESC>ddko<ESC>ddk0")
+
+ screen:expect{grid=[[
+ {2:function} {3:foo}{1:()} {1:print(}{4:"Lua!"}{1:)} {2:end} |
+ |
+ {2:local} {3:lorem} {2:=} {1:{} |
+ ^ {3:ipsum} {2:=} {1:{},} |
+ {3:bar} {2:=} {1:{},} |
+ {1:}} |
+ |
+ ]]}
+ end)
+
+end)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 93ca1aef3f..6db9e7af3e 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -522,6 +522,27 @@ describe('float window', function()
eq(5, meths.get_option_value('scroll', {win=float_win.id}))
end)
+ it(':unhide works when there are floating windows', function()
+ local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
+ local w0 = curwin()
+ meths.open_win(0, false, float_opts)
+ meths.open_win(0, false, float_opts)
+ eq(3, #meths.list_wins())
+ command('unhide')
+ eq({ w0 }, meths.list_wins())
+ end)
+
+ it(':all works when there are floating windows', function()
+ command('args Xa.txt')
+ local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
+ local w0 = curwin()
+ meths.open_win(0, false, float_opts)
+ meths.open_win(0, false, float_opts)
+ eq(3, #meths.list_wins())
+ command('all')
+ eq({ w0 }, meths.list_wins())
+ end)
+
describe('with only one tabpage,', function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local old_buf, old_win
@@ -3212,6 +3233,154 @@ describe('float window', function()
end
end)
+ describe('no crash when rearranging windows', function()
+ local function test_rearrange_windows(cmd)
+ command('set laststatus=2')
+ screen:try_resize(40, 13)
+
+ command('args X1 X2 X3 X4 X5 X6')
+ command('sargument 2')
+ command('sargument 3')
+ local w3 = curwin()
+ command('sargument 4')
+ local w4 = curwin()
+ command('sargument 5')
+ command('sargument 6')
+
+ local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 }
+ meths.win_set_config(w3, float_opts)
+ meths.win_set_config(w4, float_opts)
+ command('wincmd =')
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [8:----------------------------------------]|
+ [8:----------------------------------------]|
+ {4:X6 }|
+ [7:----------------------------------------]|
+ [7:----------------------------------------]|
+ {5:X5 }|
+ [4:----------------------------------------]|
+ [4:----------------------------------------]|
+ {5:X2 }|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {5:X1 }|
+ [3:----------------------------------------]|
+ ## grid 2
+ |
+ {0:~ }|
+ ## grid 3
+ |
+ ## grid 4
+ |
+ {0:~ }|
+ ## grid 5
+ {1: }|
+ ## grid 6
+ {1: }|
+ ## grid 7
+ |
+ {0:~ }|
+ ## grid 8
+ ^ |
+ {0:~ }|
+ ]], float_pos={
+ [5] = {{id = 1002}, "NW", 1, 6, 0, true, 50};
+ [6] = {{id = 1003}, "NW", 1, 6, 0, true, 50};
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [5] = {win = {id = 1002}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [6] = {win = {id = 1003}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [7] = {win = {id = 1004}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [8] = {win = {id = 1005}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {4:X6 }|
+ |
+ {0:~ }|
+ {5:X5 }|
+ {1: }|
+ {0:~ }|
+ {5:X2 }|
+ |
+ {0:~ }|
+ {5:X1 }|
+ |
+ ]]}
+ end
+
+ command(cmd)
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ {4:X1 }|
+ [4:----------------------------------------]|
+ {5:X2 }|
+ [9:----------------------------------------]|
+ {5:X3 }|
+ [10:----------------------------------------]|
+ {5:X4 }|
+ [7:----------------------------------------]|
+ {5:X5 }|
+ [8:----------------------------------------]|
+ {5:X6 }|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ ## grid 3
+ |
+ ## grid 4
+ |
+ ## grid 7
+ |
+ ## grid 8
+ |
+ ## grid 9
+ |
+ ## grid 10
+ |
+ ]], win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = {id = 1001}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [7] = {win = {id = 1004}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [8] = {win = {id = 1005}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [9] = {win = {id = 1006}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [10] = {win = {id = 1007}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {4:X1 }|
+ |
+ {5:X2 }|
+ |
+ {5:X3 }|
+ |
+ {5:X4 }|
+ |
+ {5:X5 }|
+ |
+ {5:X6 }|
+ |
+ ]]}
+ end
+ end
+
+ it('using :unhide', function()
+ test_rearrange_windows('unhide')
+ end)
+
+ it('using :all', function()
+ test_rearrange_windows('all')
+ end)
+ end)
+
it('API has proper error messages', function()
local buf = meths.create_buf(false,false)
eq("Invalid key: 'bork'",
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 0afa3417ec..9da20e662e 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -4,6 +4,7 @@ source shared.vim
source check.vim
source term_util.vim
source screendump.vim
+source vim9.vim
source load.vim
func s:cleanup_buffers() abort
@@ -3432,6 +3433,20 @@ func Test_autocmd_vimgrep()
augroup END
endfunc
+func Test_closing_autocmd_window()
+ let lines =<< trim END
+ edit Xa.txt
+ tabnew Xb.txt
+ autocmd BufEnter Xa.txt unhide 1
+ doautoall BufEnter
+ END
+ call CheckScriptFailure(lines, 'E814:')
+ au! BufEnter
+ only!
+ bwipe Xa.txt
+ bwipe Xb.txt
+endfunc
+
func Test_bufwipeout_changes_window()
" This should not crash, but we don't have any expectations about what
" happens, changing window in BufWipeout has unpredictable results.