Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: wrong scrollbar thumb position #759

Open
3 tasks done
aeddi opened this issue Apr 8, 2024 · 0 comments · May be fixed by #760
Open
3 tasks done

bug: wrong scrollbar thumb position #759

aeddi opened this issue Apr 8, 2024 · 0 comments · May be fixed by #760
Labels
bug Something isn't working

Comments

@aeddi
Copy link

aeddi commented Apr 8, 2024

Did you check docs and existing issues?

  • I have read all the noice.nvim docs
  • I have searched the existing issues of noice.nvim
  • 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.

without_fix.mp4

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 aeddi added the bug Something isn't working label Apr 8, 2024
@aeddi aeddi linked a pull request Apr 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant