Skip to content

bug: strange behaviour when there is already a snacks.terminal window #166

@danielyrovas

Description

@danielyrovas

Did you check docs and existing issues?

  • I have read the plugin docs
  • I have read the opencode docs
  • I have searched the existing plugin issues
  • I have searched the existing opencode issues

:checkhealth opencode output

opencode.nvim ~
- OS: Linux 6.18.3-arch1-1 (x86_64)
- `nvim` version: `0.12.0-dev+gc90593ed5f`.
- `opencode.nvim` git commit hash: `a13db1c0364319d3ebde65030005dea9f8a198cc`.
- `vim.g.opencode_opts`: {}

opencode.nvim [binaries] ~
-OK `opencode` available with version `1.1.49`.
-OK `curl` available.
-OK `pgrep` available.
-OK `lsof` available.

opencode.nvim [snacks] ~
-OK `snacks.input` is enabled: `ask()` will be enhanced.
-OK `blink.cmp` is available: `opts.ask.blink_cmp_sources` will be registered in `ask()`.
-OK `snacks.picker` is enabled: `select()` will be enhanced.

opencode.nvim [providers] ~
-OK Configured `opencode` provider: `snacks`.
-OK The `snacks` provider is available.
- ⚠️ WARNING The `kitty` provider is not availableKITTY_LISTEN_ON environment variable is not set.
  - ADVICE:
    - Enable remote control in `kitty`.
- ⚠️ WARNING The `wezterm` provider is not availableNot running in a `wezterm` window.
  - ADVICE:
    - Launch Neovim in a `wezterm` window.
- ⚠️ WARNING The `tmux` provider is not availableNot running in a `tmux` session.
  - ADVICE:
    - Launch Neovim in a `tmux` session.
-OK The `terminal` provider is available.

Describe the bug

When I toggle the opencode window <c-.>, it will open first time as usual. However, if I hide it and then open it again, the embedded opencode window visually shifts up, although the cursor is still in the normal location, along with the placeholder text.

Image

Steps To Reproduce

1. minimal.lua
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
    local lazyrepo = "https://github.com/folke/lazy.nvim.git"
    -- stylua: ignore
    local out = vim.fn.system { "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath, }
    if vim.v.shell_error ~= 0 then
        vim.api.nvim_echo({
            { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
            { out, "WarningMsg" },
            { "\nPress any key to exit..." },
        }, true, {})
        vim.fn.getchar()
        os.exit(1)
    end
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
vim.diagnostic.config({ virtual_text = false })

require("lazy").setup({
    spec = {
        {
            "nickjvandyke/opencode.nvim",
            dependencies = {
                {
                    "folke/snacks.nvim",
                    opts = { input = {}, picker = {}, terminal = {} },
                },
            },
            event = "VeryLazy",
            config = function()
                vim.g.opencode_opts = {}
                vim.o.autoread = true
            end,

            keys = {
                {
                    "<C-.>",
                    function()
                        require("opencode").ask("@this: ", { submit = true })
                    end,
                    desc = "Ask opencode…",
                    mode = { "n", "x" },
                },
                {
                    "<C-x>",
                    function()
                        require("opencode").select()
                    end,
                    desc = "Execute opencode action…",
                    mode = { "n", "x" },
                },
                {
                    "<C-a>",
                    function()
                        require("opencode").toggle()
                    end,
                    desc = "Toggle opencode",
                    mode = { "n", "t" },
                },
                {
                    "go",
                    function()
                        return require("opencode").operator("@this ")
                    end,
                    desc = "Add range to opencode",
                    mode = { "n", "x" },
                    expr = true,
                },
                {
                    "goo",
                    function()
                        return require("opencode").operator("@this ") .. "_"
                    end,
                    desc = "Add line to opencode",
                    expr = true,
                },
                {
                    "<S-C-u>",
                    function()
                        require("opencode").command("session.half.page.up")
                    end,
                    desc = "Scroll opencode up",
                },
                {
                    "<S-C-d>",
                    function()
                        require("opencode").command("session.half.page.down")
                    end,
                    desc = "Scroll opencode down",
                },
            },
        },
    },
    defaults = { lazy = true, version = false },
})
  1. :vs
  2. 3x <c-a> (or <c-.>)

Expected Behavior

It doesn't shift

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions