feat(sidebar): add member function to check whether the sidebar is focused (#1216)
This commit is contained in:
parent
a6ae8ad4b7
commit
3f8b6d07ba
@ -1257,6 +1257,20 @@ function Sidebar:initialize()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Sidebar:is_focused()
|
||||||
|
if not self:is_open() then return false end
|
||||||
|
|
||||||
|
local current_winid = api.nvim_get_current_win()
|
||||||
|
if self.winids.result_container and self.winids.result_container == current_winid then return true end
|
||||||
|
if self.winids.selected_files_container and self.winids.selected_files_container == current_winid then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if self.winids.selected_code_container and self.winids.selected_code_container == current_winid then return true end
|
||||||
|
if self.winids.input_container and self.winids.input_container == current_winid then return true end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function Sidebar:is_focused_on_result()
|
function Sidebar:is_focused_on_result()
|
||||||
return self:is_open() and self.result_container and self.result_container.winid == api.nvim_get_current_win()
|
return self:is_open() and self.result_container and self.result_container.winid == api.nvim_get_current_win()
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user