Skip to content

Commit

Permalink
fix(preview): don't error on invalid positions
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent f75992f commit 6112c3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lua/trouble/view/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ function M.open(view, item)

-- no autocmds should be triggered. So LSP's etc won't try to attach in the preview
Util.noautocmd(function()
vim.api.nvim_win_set_cursor(M.preview.win, item.pos)
vim.api.nvim_win_call(M.preview.win, function()
vim.cmd("norm! zzzv")
end)
if pcall(vim.api.nvim_win_set_cursor, M.preview.win, item.pos) then
vim.api.nvim_win_call(M.preview.win, function()
vim.cmd("norm! zzzv")
end)
end
end)

return item
Expand Down

0 comments on commit 6112c3c

Please sign in to comment.