Skip to content

Commit

Permalink
fix(fzf): add vertical offset for complex window borders
Browse files Browse the repository at this point in the history
  • Loading branch information
willothy committed Jan 23, 2024
1 parent eb3c3d8 commit e701600
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lua/dropbar/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ function dropbar_menu_t:fuzzy_find_open(opts)
local border = win_config.border
local has_left_border = false
local has_bottom_border = false
local has_top_border = false
if type(border) == 'string' then
if border ~= 'shadow' and border ~= 'none' then
has_left_border = true
Expand All @@ -953,11 +954,35 @@ function dropbar_menu_t:fuzzy_find_open(opts)
has_bottom_border = len_border == 1 and border[1] ~= ''
or len_border <= 4 and border[2] ~= ''
or border[8] ~= ''
-- remove the top border to avoid overlap with the menu
-- the fzf window will never have a title so it's safe to remove
-- the header unless the border is specified by name
if len_border == 8 then
border[1] = ''
border[2] = ''
border[3] = ''
elseif len_border == 4 then
border[1] = ''
else
-- a single char is repeated, so we create
-- a new array with the char repeated, but
-- the top border removed
local ch = border[1]
for i = 1, 8 do
if i < 4 then
border[i] = ''
else
border[i] = ch
end
end
end
end

-- make sure that fzf window aligns well with menu window
win_config.col = has_left_border and -1 or 0
win_config.row = self._win_configs.height + (has_bottom_border and 1 or 0)
win_config.row = self._win_configs.height
+ (has_bottom_border and 1 or 0)
+ (has_top_border and -1 or 0)

-- don't show title in the fzf window
win_config.title = nil
Expand Down

0 comments on commit e701600

Please sign in to comment.