Skip to content

E11 error when ModeChanged autocmd triggers in command-line window #501

@DanRioDev

Description

@DanRioDev

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

  1. Run an overseer task that creates a terminal
  2. While the task is pending, open the command-line window with q: or q/
  3. Exit the command-line window (which triggers ModeChanged *:n)
  4. 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() == ""
end

vim.fn.getcmdwintype() returns an empty string when not in the command-line window, and a non-empty string (like :, /, or ?) when inside it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions