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

The async logic does not respect the api.open { new = false } calls #492

Closed
3 tasks done
NGPONG opened this issue Jun 8, 2024 · 1 comment · Fixed by #490
Closed
3 tasks done

The async logic does not respect the api.open { new = false } calls #492

NGPONG opened this issue Jun 8, 2024 · 1 comment · Fixed by #490
Labels
bug Something isn't working

Comments

@NGPONG
Copy link

NGPONG commented Jun 8, 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.11

Operating system/version

ubuntu22.04

Describe the bug

Hello, after several days of deep usage, I feel that although the V3 version has undergone significant restructuring compared to the previous version, it is still very much worth updating. Thank you very much for your efforts @folke.

During usage, I found that sources like lsp_xxx do not respect the decision of api.open({ new = false }). This issue is particularly important for some slower LSPs. It is very difficult to clearly and completely describe an issue, so I recorded a video to demonstrate the problem I encountered (I will add any more info in the comments if needed). At the beginning of the video, I show that I have bound api.open to the de key and set new = false when calling api.open. Then, immediately after I first entered the editor, I quickly pressed the de key four times in succession. There was no response at this time, which I understand is because the LSP was too slow, so I started to wait. After a few seconds, three trouble windows popped up in succession, along with an additional warning message with no source found.

2024-06-08.175012.mp4

I'm not certain if this is the intended behavior, as my in-depth research revealed that the code only considers the open = true scenario. When open is initially called, a temporary view is stored in trouble.view._views until any data (potentially fetched asynchronously) fills this view and it gets displayed (if open_no_results = true). In my opinion, it’s necessary to include this intermediate state view within the scope of api.open({ new = false }). Should clarify that this is just my personal opinion, and I will respect any perspectives on your intended design.

opts = opts or {}
local view, _opts = M._find_last(opts)
if not view or _opts.new then

filter = filter or { open = true, mode = opts.mode }

Anyway, at least until this is properly "fixed", I am compensating for the logic of api.open({ new = false }) on the user side by hijacking the trouble.view.refresh function to broadcast whether the specified trouble mode is open. This is undoubtedly a very ugly and hacky solution.

Steps To Reproduce

see above

Expected Behavior

see above

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
@NGPONG NGPONG added the bug Something isn't working label Jun 8, 2024
@NGPONG NGPONG changed the title bug: bug: The asynchronous behavior does not respect the setting given to api.open { new = true } Jun 8, 2024
@NGPONG NGPONG changed the title bug: The asynchronous behavior does not respect the setting given to api.open { new = true } The asynchronous behavior does not respect the setting given to api.open { new = true } Jun 8, 2024
@NGPONG NGPONG changed the title The asynchronous behavior does not respect the setting given to api.open { new = true } The async behavior does not respect the setting given to api.open { new = true } Jun 8, 2024
@NGPONG NGPONG changed the title The async behavior does not respect the setting given to api.open { new = true } The async logic does not respect the api.open { new = true } calls Jun 8, 2024
@NGPONG NGPONG changed the title The async logic does not respect the api.open { new = true } calls The async logic does not respect the api.open { new = false } calls Jun 8, 2024
@folke folke closed this as completed in 57b50a6 Jun 10, 2024
@folke
Copy link
Owner

folke commented Jun 10, 2024

Should be fixed now. Thank you for reporting!

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