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 v3: using ':trouble.next' when cursor isn't in the trouble buffer often doesn't work #402

Open
3 tasks done
rgauselumifi opened this issue Mar 29, 2024 · 1 comment
Open
3 tasks done
Labels

Comments

@rgauselumifi
Copy link

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

Operating system/version

Ubuntu 22.04

Describe the bug

Most of the time, after running something like ':Trouble qflist toggle', if i then call ':lua require('trouble').next()' or ':Trouble next', it doesn't work correctly. If I move my cursor into the trouble window, and then execute ':lua require('trouble').next()', it does work.

This bug happens 80% of the time, but occasionally doesn't. To be clear, it only doesn't work if my cursor is not in the trouble buffer.

Steps To Reproduce

  1. Get data in quickfix list (using grep or whatever)
  2. Execute ":Trouble qflist toggle"
  3. Your cursor should still be in your original buffer, not the trouble one. Now execute "lua require('trouble').next()" or ":Trouble next"
  4. Most of the time, there will be a quick glitch like the screen is being redrawn, and you won't have moved to the next item in the list.

Expected Behavior

Should work with cursor outside of the buffer.

PS: side note, I noticed if I run the 'next' function when the trouble window is closed that an error occurs as the 'mode' has not been specified. I'm curious if there's a way to have the mode default to the last used one. That way if I populate the qflist or diagnostic list, I could close the trouble window and still navigate through the results.

Love the plugin, cheers my friend

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
@sand4rt
Copy link

sand4rt commented Mar 30, 2024

The keymaps from LazyVim appear to be broken in version 3 too (I changed require("trouble").previous(.. to the new api; require("trouble").prev(..):

https://github.com/LazyVim/LazyVim/blob/97480dc5d2dbb717b45a351e0b04835f138a9094/lua/lazyvim/plugins/editor.lua#L463-L492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants