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.11k stars 173 forks source link

bug: Click one of the items in the symbol outline, then click the previously opened buffer, and the window will jump multiple times. #484

Closed czfadmin closed 3 weeks ago

czfadmin commented 3 weeks ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10

Operating system/version

window 11 (wsl)

Describe the bug

Click an item in the symbol outline, then click the previously opened buffer, and the window will jump multiple times. The specific phenomenon is: after the first click, the specified symbol will be located in the open buffer window, and then click the file buffer window, and the cursor will move to the last position of the item in the outline. Click the file buffer window again to work normally(You may need to click the previously opened buffer window multiple times). When you double-click the symbol, you can jump normally.

The same problem exists in the reference outline.

image

image

Steps To Reproduce

Expected Behavior

Clicking the content in the outline has the same effect as double-clicking it, and jumps to the specified symbol position correctly.

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 3 weeks ago

Some explanation of what you're seeing:

The double click is a default keybind to jump. You can change that behavior, by adding a ["<leftmouse>"] = "jump", to jump on single click.

However, this also means you'd no longer be able to focus the trouble window.

I'll see if I can detect clicks on the main buffer window and reposition the cursor to the peview location in that case

folke commented 3 weeks ago

I was finally able to fix this. I actually looked into this issue a long time ago with Trouble v2, but never found a proper way to deal with this. But with my new changes it should all work as expected :)

czfadmin commented 3 weeks ago

I was finally able to fix this. I actually looked into this issue a long time ago with Trouble v2, but never found a proper way to deal with this. But with my new changes it should all work as expected :)

Thank you for your support and help. After updating to the latest version, the single-click effect and double-click effect now work normally.šŸ‘