folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.36k stars 175 forks source link

bug: trouble.next/prev do not update the trouble window cursor #272

Closed phallguy closed 5 months ago

phallguy commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.0-dev-1290+g2257ade3d-dirty

Operating system/version

Mac OS 13.2.1 (22D68)

Describe the bug

After TroubleToggle document_diagnostics to open a list of diagnostics and then selecting an issue, invoking require("trouble").next({ skip_groups = true, jump = true }) to navigate to the next issue does in deed take you to the next diagnostic. However, the cursor in the trouble window does not update so its not exactly clear which diagnostic you are currently viewing.

When scanning through a long list in legacy code trying to find warnings worth taking action on its easy to get lost. I would have expected to the cursor line to follow the current diagnostic when using the explicit next/previous methods -- similar to what happens in the quickfix window.

Steps To Reproduce

  1. Run TroubleToggle document_diagnostics
  2. Trouble window opens and receives focus
  3. Navigate in trouble window, select an item
  4. Target is opened in buffer
  5. Call require("trouble").next({ skip_groups = true, jump = true }) (I happen to have it bound to a keymap)
  6. Buffer is navigated to next diagnostic but the cursor in the trouble window remains on the first diagnostic

Expected Behavior

Move cursor in the trouble window to the diagnostic jumped to with trouble.next/previous.

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")
-- add anything else here
casey commented 6 months ago

Just wanted to ping this issue and note that I was having a similar issue, where the current error wasn't highlighted at all. I changed my colorscheme back to the default, and this fixed it. I don't know if it's related, since my issue was that there was no highlighting of the current error at all, and this issue sounds like it's an issue with the highlight not changing. But, if you're running into this issue, it might be worth disabling your colorscheme and seeing if that fixes it.

folke commented 5 months ago

Development on the main branch is EOL.

Trouble has been rewritten and will be merged in main soon.

This issue/feature either no longer exists or has been implemented on dev.

For more info, see https://github.com/folke/trouble.nvim/tree/dev