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: trouble quickfix takes ghostly control of cursor #336

Closed
3 tasks done
Amleto opened this issue Oct 4, 2023 · 3 comments · Fixed by #320 or #339
Closed
3 tasks done

bug: trouble quickfix takes ghostly control of cursor #336

Amleto opened this issue Oct 4, 2023 · 3 comments · Fixed by #320 or #339
Labels
bug Something isn't working

Comments

@Amleto
Copy link

Amleto commented Oct 4, 2023

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

Operating system/version

win10 22h2

Describe the bug

executing trouble.open("quickfix") and putting the cursor under the trouble group results in the cursor moving by itself. It moves one column at a time to the right until it reaches the end of the line, then it goes to the next line, starting at the first column. This repeats until it reaches the last column of the last line.

Additionally the theme is broken and the main buffer is replaced with a second trouble buffer.
From this,
image

To this,
image

Steps To Reproduce

  1. install cmake and put on PATH
  2. install clang/clangd and put on PATH
  3. clone the c++ test repo (gist)
  4. In the test repo run nvim -u repo.lua
  5. :CMakeSelectConfigurePreset - choose default
  6. :CMakeGenerate
  7. :CMakeBuild (choose ALL_BUILD if necessary)

There should be build errors - check with :cope, then close them :ccl
8. :lua require'trouble'.open'quickfix'
9. <CR> to ignore the missing web-devicons warning
10. Watch the cursor take control of itself.

Expected Behavior

The trouble quickfix buffer should open, the cursor should not go crazy, and the already-open buffer should not have its content replaced.

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
  {
    "Civitasv/cmake-tools.nvim",
    dependencies ={"nvim-lua/plenary.nvim"},
  }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@Amleto Amleto added the bug Something isn't working label Oct 4, 2023
@Amleto
Copy link
Author

Amleto commented Oct 4, 2023

1_2.C__WINDOWS_system32_cmd.exe.2023-10-04.19-56-03.mp4

screen recording of the phenomenon

@YodaEmbedding
Copy link
Contributor

YodaEmbedding commented Oct 7, 2023

See also:


The common thing in all the screen captures is when it says [1, 1]. My guess is that this happens whenever there's no exact line number or position associated with a given error, and then Trouble fills in a default value of [1, 1].

trouble

The troublesome line is marked as "BAD". When the cursor is hovered over it, everything goes haywire and the cursor starts moving right all on its own.

@Amleto
Copy link
Author

Amleto commented Oct 7, 2023

Thanks @YodaEmbedding for highlighting previous reports, and thanks @folke for the plug-in and the fix

YodaEmbedding added a commit to YodaEmbedding/trouble.nvim that referenced this issue Oct 8, 2023
folke#336.

Skip preview for non-existing buffer (`bufnr == 0`).

The vim docs say:

```
getqflist()

Quickfix list entries with a non-existing buffer
 number are returned with "bufnr" set to zero (Note: some
 functions accept buffer number zero for the alternate buffer,
 you may need to explicitly check for zero).
```

This causes trouble for the "`Trouble`" file section:

![](https://user-images.githubusercontent.com/721196/260180476-286d5945-2f53-4f2c-aedc-af793c0e96db.png)

To fix, we simply do:

```lua
function View:_preview()
  ...

  if item.bufnr == 0 then
    return
  end

  util.debug("preview")
  ...
end
```
folke pushed a commit that referenced this issue Oct 8, 2023
…338)

Skip preview for non-existing buffer (`bufnr == 0`).

The vim docs say:

```
getqflist()

Quickfix list entries with a non-existing buffer
 number are returned with "bufnr" set to zero (Note: some
 functions accept buffer number zero for the alternate buffer,
 you may need to explicitly check for zero).
```

This causes trouble for the "`Trouble`" file section:

![](https://user-images.githubusercontent.com/721196/260180476-286d5945-2f53-4f2c-aedc-af793c0e96db.png)

To fix, we simply do:

```lua
function View:_preview()
  ...

  if item.bufnr == 0 then
    return
  end

  util.debug("preview")
  ...
end
```
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