Skip to content

Commit

Permalink
fix(telescope): show error when use tries to add when telescope picke…
Browse files Browse the repository at this point in the history
…r does not exist
  • Loading branch information
folke committed Jun 7, 2024
1 parent 7d512d5 commit c11dc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/trouble/sources/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---@diagnostic disable: inject-field
local Item = require("trouble.item")
local Util = require("trouble.util")

---Represents an item in a Neovim quickfix/loclist.
---@class telescope.Item
Expand Down Expand Up @@ -57,6 +58,9 @@ function M.add(prompt_bufnr, opts)
local action_state = require("telescope.actions.state")
---@type Picker
local picker = action_state.get_current_picker(prompt_bufnr)
if not picker then
return Util.error("No Telescope picker found?")
end

if #picker:get_multi_selection() > 0 then
for _, item in ipairs(picker:get_multi_selection()) do
Expand Down
4 changes: 3 additions & 1 deletion lua/trouble/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ end
function M:jump(item, opts)
opts = opts or {}
item = item or self:at().item
Preview.close()
vim.schedule(function()
Preview.close()
end)
if not item then
return Util.warn("No item to jump to")
end
Expand Down

0 comments on commit c11dc27

Please sign in to comment.