Skip to content

Commit 76dd1b4

Browse files
authored
fix: set max height for popup help window (#1213)
1 parent 936b029 commit 76dd1b4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lua/neo-tree/sources/common/help.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@ M.show = function(state, title, prefix_key)
8989
zindex = 50,
9090
relative = "editor",
9191
}
92+
93+
local popup_max_height = function()
94+
local lines = vim.o.lines
95+
local cmdheight = vim.o.cmdheight
96+
-- statuscolumn
97+
local statuscolumn_lines = 0
98+
local laststatus = vim.o.laststatus
99+
if laststatus ~= 0 then
100+
local windows = vim.api.nvim_tabpage_list_wins(0)
101+
if (laststatus == 1 and #windows > 1) or laststatus > 1 then
102+
statuscolumn_lines = 1
103+
end
104+
end
105+
-- tabs
106+
local tab_lines = 0
107+
local showtabline = vim.o.showtabline
108+
if showtabline ~= 0 then
109+
local tabs = vim.api.nvim_list_tabpages()
110+
if (showtabline == 1 and #tabs > 1) or showtabline == 2 then
111+
tab_lines = 1
112+
end
113+
end
114+
return lines - cmdheight - statuscolumn_lines - tab_lines - 1
115+
end
116+
local max_height = popup_max_height()
117+
if options.size.height > max_height then
118+
options.size.height = max_height
119+
end
120+
92121
local title = title or "Neotree Help"
93122
local options = popups.popup_options(title, width, options)
94123
local popup = Popup(options)

0 commit comments

Comments
 (0)