From cf140fb25b94c556396fe942a4af3e8db9effa37 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 27 Jul 2023 01:38:23 +0100 Subject: vim-patch:9.1.0047: issues with temp curwin/buf while cmdwin is open Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Reset and save `cmdwin_old_curwin` in a similar fashion. Apply suitable changes for API functions and add Lua tests. https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f --- test/functional/vimscript/api_functions_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 200ad40c3a..4985768bb0 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear = helpers.clear local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval +local exec_lua = helpers.exec_lua local insert, pcall_err = helpers.insert, helpers.pcall_err local matches = helpers.matches local api = helpers.api @@ -106,6 +107,19 @@ describe('eval-API', function() pcall_err(api.nvim_open_term, 0, {}) ) + matches( + 'E11: Invalid in command%-line window; executes, CTRL%-C quits$', + pcall_err( + exec_lua, + [[ + local cmdwin_buf = vim.api.nvim_get_current_buf() + vim.api.nvim_buf_call(vim.api.nvim_create_buf(false, true), function() + vim.api.nvim_open_term(cmdwin_buf, {}) + end) + ]] + ) + ) + -- But turning a different buffer into a terminal from the cmdwin is OK. local term_buf = api.nvim_create_buf(false, true) api.nvim_open_term(term_buf, {}) -- cgit