diff --git a/lua/cmp/utils/window.lua b/lua/cmp/utils/window.lua index 80fb9f5..3779aa2 100644 --- a/lua/cmp/utils/window.lua +++ b/lua/cmp/utils/window.lua @@ -133,7 +133,7 @@ end ---Update window.update = function(self) local info = self:info() - if info.scrollable then + if info.scrollable and self.style.height > 0 then -- Draw the background of the scrollbar if not info.border_info.visible then diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index dc7564d..9a665b1 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -212,7 +212,14 @@ custom_entries_view.open = function(self, offset, entries) border = completion.border, zindex = completion.zindex or 1001, }) - -- always set cursor when starting. It will be adjusted on the call to _select + + -- Don't set the cursor if the entries_win:open function fails + -- due to the window's width or height being less than 1 + if self.entries_win.win == nil then + return + end + + -- Always set cursor when starting. It will be adjusted on the call to _select vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 0 }) if preselect_index > 0 and config.get().preselect == types.cmp.PreselectMode.Item then self:_select(preselect_index, { behavior = types.cmp.SelectBehavior.Select, active = false })