-
Notifications
You must be signed in to change notification settings - Fork 97
E11 error when ModeChanged autocmd triggers in command-line window #501
Copy link
Copy link
Open
Description
Description
When a task is queued for terminal creation and the user is in the command-line window (q:, q/, etc.), the ModeChanged autocmd triggers and attempts to call nvim_open_win, which throws E11: Invalid in command-line window.
Error Message
Error in ModeChanged Autocommands for "*:n":
Lua callback: ...ocal/share/nvim/lazy/overseer.nvim/lua/overseer/util.lua:633: E11: Invalid in command-line window; <CR> executes, CTRL-C quits
stack traceback:
[C]: in function 'nvim_open_win'
...ocal/share/nvim/lazy/overseer.nvim/lua/overseer/util.lua:633: in function 'run_in_fullscreen_win'
...im/lazy/overseer.nvim/lua/overseer/strategy/jobstart.lua:130: in function '_create_terminal'
...im/lazy/overseer.nvim/lua/overseer/strategy/jobstart.lua:103: in function <...im/lazy/overseer.nvim/lua/overseer/strategy/jobstart.lua:98>
Root Cause
The can_create_terminal() function in lua/overseer/strategy/jobstart.lua (lines 91-94) checks:
vim.api.nvim_get_mode().mode == "n"not util.is_floating_win(0)
However, the command-line window reports mode as "n" (normal), but has special restrictions where nvim_open_win is not allowed.
Reproduction Steps
- Run an overseer task that creates a terminal
- While the task is pending, open the command-line window with
q:orq/ - Exit the command-line window (which triggers
ModeChanged *:n) - Error occurs
Suggested Fix
Add a check for the command-line window in can_create_terminal():
local function can_create_terminal()
return vim.api.nvim_get_mode().mode == "n"
and not util.is_floating_win(0)
and vim.fn.getcmdwintype() == ""
endvim.fn.getcmdwintype() returns an empty string when not in the command-line window, and a non-empty string (like :, /, or ?) when inside it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels