Skip to content

Commit

Permalink
fix(menu): should close existing sub-menus on opening sub-menus (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed May 31, 2023
1 parent 8cb3ab8 commit 10318d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/dropbar/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,14 @@ function dropbar_menu_t:open()
if self.is_opened then
return
end
self.is_opened = true

self.prev_win = vim.api.nvim_get_current_win()
local parent_menu = _G.dropbar.menus[self.prev_win]
if parent_menu then
-- if the parent menu has an existing sub-menu, close the sub-menu first
if parent_menu.sub_menu then
parent_menu.sub_menu:close()
end
parent_menu.sub_menu = self
self.parent_menu = parent_menu
self.prev_win = parent_menu.win
Expand All @@ -375,6 +378,7 @@ function dropbar_menu_t:open()
self:eval_win_config()
self:make_buf()
self.win = vim.api.nvim_open_win(self.buf, true, self._win_configs)
self.is_opened = true
vim.wo[self.win].scrolloff = 0
vim.wo[self.win].sidescrolloff = 0
_G.dropbar.menus[self.win] = self
Expand Down

0 comments on commit 10318d1

Please sign in to comment.