Skip to content

Commit

Permalink
fix(view): docs_view should go bottom_up if custom_entries_view
Browse files Browse the repository at this point in the history
… did
  • Loading branch information
llllvvuu committed Oct 8, 2023
1 parent 4f3aa60 commit 7fd5fad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lua/cmp/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ view.open_docs = function(self)
if not self:visible() then
return
end
self.docs_view:open(e, self:_get_entries_view():info())
local bottom_up = self.custom_entries_view.bottom_up
self.docs_view:open(e, self:_get_entries_view():info(), bottom_up)
end)))
end
end
Expand Down Expand Up @@ -268,7 +269,8 @@ view.on_entry_change = async.throttle(function(self)
return
end
if self.is_docs_view_pinned or config.get().view.docs.auto_open then
self.docs_view:open(e, self:_get_entries_view():info())
local bottom_up = self.custom_entries_view.bottom_up
self.docs_view:open(e, self:_get_entries_view():info(), bottom_up)
end
end)))
else
Expand Down
1 change: 1 addition & 0 deletions lua/cmp/view/custom_entries_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local DEFAULT_HEIGHT = 10 -- @see https://github.com/vim/vim/blob/master/src/pop
---@field private active boolean
---@field private entries cmp.Entry[]
---@field private column_width any
---@field private bottom_up boolean
---@field public event cmp.Event
local custom_entries_view = {}

Expand Down
7 changes: 5 additions & 2 deletions lua/cmp/view/docs_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ end
---Open documentation window
---@param e cmp.Entry
---@param view cmp.WindowStyle
docs_view.open = function(self, e, view)
---@param bottom_up boolean
docs_view.open = function(self, e, view, bottom_up)
local documentation = config.get().window.documentation
if not documentation then
return
Expand Down Expand Up @@ -90,6 +91,8 @@ docs_view.open = function(self, e, view)
return self:close()
end

local row = bottom_up and math.max(view.row - (height + border_info.vert - view.height), 1) or view.row

-- Render window.
self.window:option('winblend', vim.o.pumblend)
self.window:option('winhighlight', documentation.winhighlight)
Expand All @@ -98,7 +101,7 @@ docs_view.open = function(self, e, view)
style = 'minimal',
width = width,
height = height,
row = view.row,
row = row,
col = col,
border = documentation.border,
zindex = documentation.zindex or 50,
Expand Down

0 comments on commit 7fd5fad

Please sign in to comment.