Skip to content

Commit

Permalink
fix(preview): skip non-existing. Fixes #87. Fixes #188. Fixes #336. (#…
Browse files Browse the repository at this point in the history
…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
```
  • Loading branch information
YodaEmbedding committed Oct 8, 2023
1 parent 2ea761f commit 5e78824
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/trouble/view.lua
Expand Up @@ -495,6 +495,10 @@ function View:_preview()
if not item then
return
end
if item.bufnr == 0 then
return
end

util.debug("preview")

if item.is_file ~= true then
Expand Down

0 comments on commit 5e78824

Please sign in to comment.