Skip to content

Commit

Permalink
fix(menu): highlighting issues that occur during menu navigation (#52)
Browse files Browse the repository at this point in the history
* fix(menu): preview doesn't update on menu reopen

- remove the check if cursor is same as prev_cursor field, which
  prevents preview updating when returning to an existing menu window

* fix(menu): context highlight not restored when submenu closed

When a submenu is closed and the parent menu regains focus, restore the
context highlight if it is set (i.e. if the cursor field is set).
Otherwise clear the context highlight.

* fix(menu): hover highlight broken if quick navigation disabled

In CursorMoved autocmd, the prev_cursor field is only updated through
the quick_navigation function. The hover highlight update takes the
prev_cursor field as an argument and so prior to this fix, the hover
highlight would only be updated when the quick navigation config option
was enabled
  • Loading branch information
theofabilous authored and bekaboo committed Jul 8, 2023
1 parent 5aec53c commit a34d3e6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lua/dropbar/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,14 @@ function dropbar_menu_t:make_buf()
callback = function()
local cursor = vim.api.nvim_win_get_cursor(self.win)

if
configs.opts.menu.preview
and not vim.deep_equal(cursor, self.prev_cursor)
then
if configs.opts.menu.preview then
self:preview_symbol_at(cursor, true)
end

if configs.opts.menu.quick_navigation then
self:quick_navigation(cursor)
else
self.prev_cursor = cursor
end

-- Update hover highlights
Expand Down Expand Up @@ -529,6 +528,14 @@ function dropbar_menu_t:close(restore_view)
end
-- Move cursor to the previous window
if self.prev_win and vim.api.nvim_win_is_valid(self.prev_win) then
local prev_menu = _G.dropbar.menus[self.prev_win]
if prev_menu then
if prev_menu.cursor then
prev_menu:update_current_context_hl(prev_menu.cursor[1])
else
prev_menu:update_current_context_hl(nil)
end
end
vim.api.nvim_set_current_win(self.prev_win)
end
-- Close the menu window and dereference it in the lookup table
Expand Down

0 comments on commit a34d3e6

Please sign in to comment.