From 2b7c2d53363cb3d93376904dac3ea6d52dd900c5 Mon Sep 17 00:00:00 2001 From: bekaboo <18127878294@qq.com> Date: Sun, 3 Dec 2023 12:55:26 +0800 Subject: [PATCH] fix(menu-scrollbar): scrollbar thumb covered by menu border --- README.md | 16 ++++++++++++++++ doc/dropbar.txt | 8 ++++++++ lua/dropbar/configs.lua | 8 ++++++++ lua/dropbar/menu.lua | 18 ++++++++++-------- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 25aa2fd3..d32b01e9 100644 --- a/README.md +++ b/README.md @@ -553,6 +553,14 @@ https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975- end, menu.entries))) ) end, + zindex = function(menu) + if menu.prev_menu then + if menu.prev_menu.scrollbar and menu.prev_menu.scrollbar.thumb then + return vim.api.nvim_win_get_config(menu.prev_menu.scrollbar.thumb).zindex + end + return vim.api.nvim_win_get_config(menu.prev_win).zindex + end + end, }, }, fzf = { @@ -1176,6 +1184,14 @@ menu: end, menu.entries))) ) end, + zindex = function(menu) + if menu.prev_menu then + if menu.prev_menu.scrollbar and menu.prev_menu.scrollbar.thumb then + return vim.api.nvim_win_get_config(menu.prev_menu.scrollbar.thumb).zindex + end + return vim.api.nvim_win_get_config(menu.prev_win).zindex + end + end, } ``` diff --git a/doc/dropbar.txt b/doc/dropbar.txt index 5cca0b28..48c5eec2 100644 --- a/doc/dropbar.txt +++ b/doc/dropbar.txt @@ -598,6 +598,14 @@ the menu: end, menu.entries))) ) end, + zindex = function(menu) + if menu.prev_menu then + if menu.prev_menu.scrollbar and menu.prev_menu.scrollbar.thumb then + return vim.api.nvim_win_get_config(menu.prev_menu.scrollbar.thumb).zindex + end + return vim.api.nvim_win_get_config(menu.prev_win).zindex + end + end, } < diff --git a/lua/dropbar/configs.lua b/lua/dropbar/configs.lua index fa7e2526..06dae5ad 100644 --- a/lua/dropbar/configs.lua +++ b/lua/dropbar/configs.lua @@ -319,6 +319,14 @@ M.opts = { end, menu.entries))) ) end, + zindex = function(menu) + if menu.prev_menu then + if menu.prev_menu.scrollbar and menu.prev_menu.scrollbar.thumb then + return vim.api.nvim_win_get_config(menu.prev_menu.scrollbar.thumb).zindex + end + return vim.api.nvim_win_get_config(menu.prev_win).zindex + end + end, }, }, fzf = { diff --git a/lua/dropbar/menu.lua b/lua/dropbar/menu.lua index c93c99f0..44c9ef83 100644 --- a/lua/dropbar/menu.lua +++ b/lua/dropbar/menu.lua @@ -566,32 +566,34 @@ function dropbar_menu_t:update_scrollbar() else self:close_scrollbar() self.scrollbar = {} + local win_configs = { - row = offset, + row = 0, col = menu_win_configs.width, width = 1, - height = thumb_height, + height = menu_win_configs.height, style = 'minimal', border = 'none', relative = 'win', win = self.win, zindex = menu_win_configs.zindex, } - self.scrollbar.thumb = vim.api.nvim_open_win( + self.scrollbar.sbar = vim.api.nvim_open_win( vim.api.nvim_create_buf(false, true), false, win_configs ) - vim.wo[self.scrollbar.thumb].winhl = 'NormalFloat:DropBarMenuThumb' + vim.wo[self.scrollbar.sbar].winhl = 'NormalFloat:DropBarMenuSbar' - win_configs.row = 0 - win_configs.height = menu_win_configs.height - self.scrollbar.sbar = vim.api.nvim_open_win( + win_configs.row = offset + win_configs.height = thumb_height + win_configs.zindex = menu_win_configs.zindex + 1 + self.scrollbar.thumb = vim.api.nvim_open_win( vim.api.nvim_create_buf(false, true), false, win_configs ) - vim.wo[self.scrollbar.sbar].winhl = 'NormalFloat:DropBarMenuSbar' + vim.wo[self.scrollbar.thumb].winhl = 'NormalFloat:DropBarMenuThumb' end end