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.24k stars 178 forks source link

fix(preview): skip non-existing. Fixes #87. Fixes #188. Fixes #336. #338

Closed YodaEmbedding closed 10 months ago

YodaEmbedding commented 10 months ago

Continuation of 46b60e9.

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:

To fix, we simply do:

function View:_preview()
  ...

  if item.bufnr == 0 then
    return
  end

  util.debug("preview")
  ...
end
folke commented 10 months ago

Thanks!