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.12k stars 172 forks source link

bug: Trouble opens when there are no results, even when open_no_results is set to false. #460

Closed nolanpollack closed 1 month ago

nolanpollack commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

WSL 2.0.14.0

Describe the bug

When I set open_no_results to false (which should be the default), it should presumably not "open the trouble window when there are no results". However, the trouble window still opens when I use the Trouble command, specifically with lsp_references (though the same behavior seems to apply with other modes). Similarly, there appears to be no warning when warn_no_results is set to true.

When I set auto_close to true, the trouble window will open, then immediately close.

Perhaps I am misunderstanding the meaning of a "result" versus an "item". I'd like the trouble command to do nothing when there are no references under the cursor.

Steps To Reproduce

  1. Move cursor to an area where there are no lsp references
  2. :Trouble lsp_references open_no_results=false warn_no_results=true

Expected Behavior

Should not open the trouble window.

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
folke commented 1 month ago

Are you 100% sure you're using the latest version?

nolanpollack commented 1 month ago

Are you 100% sure you're using the latest version?

My bad! I was on an earlier version.

folke commented 1 month ago

Please always update your plugins if you have an issue