Skip to content

[BUG] Vertical and Horizontal directions don't work when Snacks Explorer focused #660

Open

Description

@cat-phish

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I get an invalid direction when I have Snacks Explorer focused. Spent a bunch of time trouble shooting, and realized this was the only cause. It only happens at first launch when the picker is automatically focused. It seems like it's probably a ToggleTerm issue so I'm posting here.

This is the only error message I get:

  ...ckages/start/toggleterm.nvim/lua/toggleterm/terminal.lua:466: Invalid terminal direction

Expected Behavior

ToggleTerm should toggle regardless.

Steps To Reproduce

  1. nvim .
  2. Snacks Explorer is focused
  3. C-\
  4. Error

Environment

- OS:
- neovim version:
- Shell:

Anything else?

No response

Activity

  1. apple1417 commented on Feb 2, 2026

    @apple1417

    I was running into the same issue, and did some debugging.

    Firstly, one important behavior to note is it's only an issue if the first time you try open a terminal is with explorer focused - if you've already opened/closed it in another window, opening will work fine from the explorer.

    The issue starts here - the error we're seeing is the one at the end of the function:

    ---Open a terminal in a type of window i.e. a split,full window or tab
    ---@param size number
    ---@param term table
    local function opener(size, term)
    local direction = term.direction
    if term:is_split() then
    ui.open_split(size, term)
    elseif direction == "tab" then
    ui.open_tab(term)
    elseif direction == "float" then
    ui.open_float(term)
    else
    error("Invalid terminal direction")
    end
    end

    We get the error when term:is_split() returns false, on all successful attempts it returns true. Following it.

    function Terminal:is_split()
    return (self.direction == "vertical" or self.direction == "horizontal")
    and not ui.is_float(self.window)
    end

    ---Determine if a window is a float
    ---@param window number
    function M.is_float(window) return fn.win_gettype(window) == "popup" end

    With some logging, I found the very first time you open the terminal, self.window isn't set - which makes sense since it hasn't opened the window yet. This means it passes nil to win_gettype, which ends up returning the type of the current window. This seems like the root bug? Snacks explorer is a pop up, so if you open your first terminal with it (or any other popup) selected, self.window is nil so is_float will return true, causing is_split to return false, and opener to error.

  2. added a commit that references this issue on Feb 2, 2026
    bafdc05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions