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: scrolling through items does not always highlight correct range in preview #476

Closed
3 tasks done
tom-anders opened this issue Jun 3, 2024 · 3 comments · Fixed by #461
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@tom-anders
Copy link
Contributor

tom-anders commented Jun 3, 2024

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.0

Operating system/version

Ubuntu 22

Describe the bug

When scrolling though trouble with j/k, the range of the item under the cursor is not always highlighted correctly in the preview.

This seems to happen if two items have the same line number, but different columns. (Update: I also observed this where all items have different line numbers. It only seems to happen to the first item in the list though)

Correct highlight for 2nd item:

image

Incorrect highlight for 1st item:

image

Steps To Reproduce

  1. nvim -u repro.lua (see below)
  2. scroll through list with j/k and observe highlighting in preview=

Expected Behavior

The range of the item under the cursor should be highlighted in the preview

Repro

-- DO NOT change the paths and don't remove the colorscheme
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/trouble.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

vim.cmd.edit("repro.lua")

vim.fn.setqflist({
   {
       bufnr = 0,
       lnum = 1,
       col = 0,
       end_col = 4,
       text = "hello",
   },
   {
       bufnr = 0,
       lnum = 1,
       col = 8,
       end_col = 12,
       text = "world",
   },
})

local ns = vim.api.nvim_create_namespace("repro")
vim.diagnostic.set(ns, 0, {
  {
    bufnr = 0,
    lnum = 1,
    col = 0,
    end_col = 10,
    message = "d1",
  },
  {
    bufnr = 0,
    lnum = 1,
    col = 12,
    end_col = 25,
    message = "d2",
  },
  {
    bufnr = 0,
    lnum = 5,
    col = 1,
    end_col = 15,
    message = "d3",
  },
  {
    bufnr = 0,
    lnum = 5,
    col = 16,
    end_col = 25,
    message = "d4",
  },
})

require'trouble'.open({mode = "diagnostics", focus = true})
@tom-anders tom-anders added the bug Something isn't working label Jun 3, 2024
@tom-anders
Copy link
Contributor Author

Update: also happens for the last item in the list sometimes

@folke folke closed this as completed in 13ad959 Jun 3, 2024
@folke
Copy link
Owner

folke commented Jun 3, 2024

Fixed. Thank you for reporting!

@tom-anders
Copy link
Contributor Author

fix confirmed, thanks for the quick response!

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.

2 participants