noice.nvim icon indicating copy to clipboard operation
noice.nvim copied to clipboard

bug: wrong scrollbar thumb position

Open aeddi opened this issue 2 months ago • 0 comments

Did you check docs and existing issues?

  • [X] I have read all the noice.nvim docs
  • [X] I have searched the existing issues of noice.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.5

Operating system/version

macOS 14.0 (23A344)

Describe the bug

In the hover/signature window, the thumb position of scrollbars is wrong because its calculation is based on the position of the cursor in the buffer and not on the buffer lines displayed in the window.

See the attached video.

https://github.com/folke/noice.nvim/assets/5222525/2abe3933-379c-4eed-8903-1fabdb8a42e0

Steps To Reproduce

  1. Create a minimal configuration file based on the one in the documentation.
  2. Add and configure an LSP server (in this example lua_lsp) and a few keymaps to interact with the hover window (see details below).
  3. Display a hover window (by pressing the K key in normal mode in my case) then use require("noice.lsp").scroll until the last line of the buffer is displayed (by pressing <C-f> several times in my case). You can see that the position of the scrollbar thumb is wrong.
  4. Focus the hover window (by pressing K in normal mode in my case), press G to jump to the last line of the buffer, move the cursor up a few lines (by pressing 10k for example). As you can see once again : the position of the scrollbar thumb is wrong.

Expected Behavior

The position of the scrollbar thumb should be correct and based on the buffer lines displayed in the window rather than the cursor position.

Repro

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "folke/noice.nvim",
    dependencies = {
      "MunifTanjim/nui.nvim",
      "rcarriga/nvim-notify",
    },
  },
  -- add any other plugins here
  "neovim/nvim-lspconfig",
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

-- add anything else here
require("noice").setup()
require("lspconfig").lua_ls.setup({
  settings = {
    Lua = {
      workspace = {
        library = {
          vim.env.VIMRUNTIME,
        },
      },
    },
  },
})

-- keymap for lsp hover interactions
vim.keymap.set("n", "K", vim.lsp.buf.hover)

vim.keymap.set({ "n", "i", "s" }, "<c-f>", function()
  if not require("noice.lsp").scroll(4) then
    return "<c-f>"
  end
end, { silent = true, expr = true })

vim.keymap.set({ "n", "i", "s" }, "<c-b>", function()
  if not require("noice.lsp").scroll(-4) then
    return "<c-b>"
  end
end, { silent = true, expr = true })

aeddi avatar Apr 08 '24 15:04 aeddi