Skip to content

Commit 7fd5fad

Browse files
committed
fix(view): docs_view should go bottom_up if custom_entries_view did
1 parent 4f3aa60 commit 7fd5fad

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

lua/cmp/view.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ view.open_docs = function(self)
171171
if not self:visible() then
172172
return
173173
end
174-
self.docs_view:open(e, self:_get_entries_view():info())
174+
local bottom_up = self.custom_entries_view.bottom_up
175+
self.docs_view:open(e, self:_get_entries_view():info(), bottom_up)
175176
end)))
176177
end
177178
end
@@ -268,7 +269,8 @@ view.on_entry_change = async.throttle(function(self)
268269
return
269270
end
270271
if self.is_docs_view_pinned or config.get().view.docs.auto_open then
271-
self.docs_view:open(e, self:_get_entries_view():info())
272+
local bottom_up = self.custom_entries_view.bottom_up
273+
self.docs_view:open(e, self:_get_entries_view():info(), bottom_up)
272274
end
273275
end)))
274276
else

lua/cmp/view/custom_entries_view.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local DEFAULT_HEIGHT = 10 -- @see https://github.com/vim/vim/blob/master/src/pop
1616
---@field private active boolean
1717
---@field private entries cmp.Entry[]
1818
---@field private column_width any
19+
---@field private bottom_up boolean
1920
---@field public event cmp.Event
2021
local custom_entries_view = {}
2122

lua/cmp/view/docs_view.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ end
2525
---Open documentation window
2626
---@param e cmp.Entry
2727
---@param view cmp.WindowStyle
28-
docs_view.open = function(self, e, view)
28+
---@param bottom_up boolean
29+
docs_view.open = function(self, e, view, bottom_up)
2930
local documentation = config.get().window.documentation
3031
if not documentation then
3132
return
@@ -90,6 +91,8 @@ docs_view.open = function(self, e, view)
9091
return self:close()
9192
end
9293

94+
local row = bottom_up and math.max(view.row - (height + border_info.vert - view.height), 1) or view.row
95+
9396
-- Render window.
9497
self.window:option('winblend', vim.o.pumblend)
9598
self.window:option('winhighlight', documentation.winhighlight)
@@ -98,7 +101,7 @@ docs_view.open = function(self, e, view)
98101
style = 'minimal',
99102
width = width,
100103
height = height,
101-
row = view.row,
104+
row = row,
102105
col = col,
103106
border = documentation.border,
104107
zindex = documentation.zindex or 50,

0 commit comments

Comments
 (0)