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: Click one of the items in the symbol outline, then click the previously opened buffer, and the window will jump multiple times. #484

Closed
3 tasks done
czfadmin opened this issue Jun 6, 2024 · 3 comments · Fixed by #486
Labels
bug Something isn't working

Comments

@czfadmin
Copy link

czfadmin commented Jun 6, 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

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.

  • first click
    image
  • click the opened buffer
    image

The same problem exists in the reference outline.

image

image

Steps To Reproduce

  • open outline
  • Click any symbol in the outline
  • Click the previously opened buffer window

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
@czfadmin czfadmin added the bug Something isn't working label Jun 6, 2024
@folke
Copy link
Owner

folke commented Jun 6, 2024

Some explanation of what you're seeing:

  • When you click on an item in the doc symbols, or any other item, a preview will open of the item location.
  • The default preview has type main which is a floating window displayed over your main editor window that pretty much looks the same as your real window
  • When you click on that preview window, you're leaving the trouble window
  • When leaving the trouble window, the preview is automatically closed
  • So you'll see the window return to the state as before

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 folke closed this as completed in 98d9ed7 Jun 6, 2024
@folke
Copy link
Owner

folke commented Jun 6, 2024

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
Copy link
Author

czfadmin commented Jun 7, 2024

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.👍

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