Skip to content

bug: sidekick panel horizontal scroll offset after close/reopen #292

@oleynikandrey

Description

@oleynikandrey

Did you check docs and existing issues?

  • I have read all the sidekick.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of sidekick.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.12.0

Operating system/version

MacOS 26.4

Describe the bug

When the sidekick CLI panel is closed and reopened (e.g. via <c-.>), the panel content shifts to the left — the first several columns become invisible, as if leftcol is non-zero.

Steps To Reproduce

  1. Open sidekick panel with a CLI tool (Claude Code in my case)
  2. Close the panel with <c-.>
  3. Reopen the panel with <c-.>
  4. The left edge of the terminal content is cut off (e.g. status line shows ERT -- instead of INSERT --)

Expected Behavior

Cause

open_win() in terminal.lua creates a new window for the existing buffer via nvim_open_win(), but never resets the horizontal scroll position. The scroll() function in scrollback.lua (line 246) restores topline, lnum, and col but omits leftcol:

  vim.fn.winrestview({
    topline = topline,
    lnum = lnum,
    col = col,
  })

When the buffer had any horizontal scroll before the window was closed, the new window inherits the stale leftcol, cutting off the left columns.

Suggested fix

Add leftcol = 0 to the winrestview() call, or reset it in open_win() after creating the window:

  vim.fn.winrestview({
    topline = topline,
    lnum = lnum,
    col = col,
    leftcol = 0,
  })

Workaround

Wrapping open_win via the config callback:

  opts = {
    cli = {
      win = {
        config = function(terminal)
          local orig_open_win = terminal.open_win
          function terminal:open_win()
            orig_open_win(self)
            if self.win and vim.api.nvim_win_is_valid(self.win) then
              vim.api.nvim_win_call(self.win, function()
                vim.fn.winrestview({ leftcol = 0 })
              end)
            end
          end
        end,
      },
    },
  }

Repro

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