Skip to content

Commit

Permalink
Bugfix: after closing the telescope prompt, the focus wouldn't go back
Browse files Browse the repository at this point in the history
to the neogit buffer if it was open as a split.

This ensures that the status buffer is refocused just before the
on_select function is called. If on_select() opens a new popup, then the
popup is correctly split from the status buffer.
  • Loading branch information
CKolkey committed Aug 2, 2023
1 parent 656b40e commit 35e191b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lua/neogit/lib/finder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ local function telescope_mappings(on_select, allow_multi)
local action_state = require("telescope.actions.state")
local actions = require("telescope.actions")

local function close_action(prompt_bufnr)
actions.close(prompt_bufnr)

local status = require("neogit.status")
if status.status_buffer then
status.status_buffer:focus()
end
end

--- Lift the picker select action to a item select action
local function select_action(prompt_bufnr)
local selection = {}
Expand All @@ -22,7 +31,7 @@ local function telescope_mappings(on_select, allow_multi)
return
end

actions.close(prompt_bufnr)
close_action(prompt_bufnr)

if allow_multi then
on_select(selection)
Expand All @@ -37,7 +46,7 @@ local function telescope_mappings(on_select, allow_multi)
["Close"] = function(...)
-- Make sure to notify the caller that we aborted to avoid hanging on the async task forever
on_select(nil)
actions.close(...)
close_action(...)
end,
["Next"] = actions.move_selection_next,
["Previous"] = actions.move_selection_previous,
Expand Down

0 comments on commit 35e191b

Please sign in to comment.