Skip to content

Commit c8cf209

Browse files
committedNov 4, 2024
fix: scrollbar gutter not updating on window resize
1 parent 4c2a36c commit c8cf209

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
 

‎lua/blink/cmp/windows/lib/scrollbar/geometry.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ local function get_win_buf_height(target_win)
2929
end
3030

3131
--- @param target_win number
32-
--- @return { should_hide: boolean, thumb: blink.cmp.ScrollbarGeometry, gutter: blink.cmp.ScrollbarGeometry }
32+
--- @return { should_hide_thumb: boolean, thumb: blink.cmp.ScrollbarGeometry, gutter: blink.cmp.ScrollbarGeometry }
3333
function M.get_geometry(target_win)
3434
local width = vim.api.nvim_win_get_width(target_win)
3535
local height = vim.api.nvim_win_get_height(target_win)
@@ -52,7 +52,7 @@ function M.get_geometry(target_win)
5252
}
5353

5454
return {
55-
should_hide = height >= buf_height,
55+
should_hide_thumb = height >= buf_height,
5656
thumb = vim.tbl_deep_extend('force', common_geometry, { height = thumb_height, zindex = zindex + 2 }),
5757
gutter = vim.tbl_deep_extend('force', common_geometry, { row = 0, height = height, zindex = zindex + 1 }),
5858
}

‎lua/blink/cmp/windows/lib/scrollbar/init.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ function scrollbar:mount(target_win)
4040
if not vim.api.nvim_win_is_valid(target_win) then return self:unmount() end
4141

4242
local updated_geometry = require('blink.cmp.windows.lib.scrollbar.geometry').get_geometry(target_win)
43-
if updated_geometry.should_hide then return self.win:hide_thumb() end
44-
45-
self.win:show_thumb(updated_geometry.thumb)
4643
self.win:show_gutter(updated_geometry.gutter)
44+
if updated_geometry.should_hide_thumb then
45+
self.win:hide_thumb()
46+
else
47+
self.win:show_thumb(updated_geometry.thumb)
48+
end
4749
end
4850
-- HACK: for some reason, the autocmds don't fire on the initial mount
4951
-- so we apply after on the next event loop iteration after the windows are definitely setup

0 commit comments

Comments
 (0)