Skip to content

Commit

Permalink
fix: stack overflow in telescope (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Apr 23, 2022
1 parent cad08fa commit f68a91a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lua/dressing/select/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ M.select = function(config, items, opts, on_choice)
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = state.get_selected_entry()
actions._close(prompt_bufnr, false)
local callback = on_choice
-- Replace on_choice with a no-op so closing doesn't trigger it
on_choice = function() end
actions.close(prompt_bufnr)
if not selection then
-- User did not select anything.
on_choice(nil, nil)
callback(nil, nil)
return
end
local idx = nil
Expand All @@ -52,13 +55,14 @@ M.select = function(config, items, opts, on_choice)
break
end
end
on_choice(selection.value, idx)
callback(selection.value, idx)
end)

actions.close:replace(function()
actions._close(prompt_bufnr, false)
on_choice(nil, nil)
end)
actions.close:enhance({
post = function()
on_choice(nil, nil)
end,
})

return true
end,
Expand Down

0 comments on commit f68a91a

Please sign in to comment.