Skip to content

Commit 5df54f6

Browse files
committed
Also make picker height flex by content
1 parent 4607a17 commit 5df54f6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/vim_cycle/telescope.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ local entry_display = require 'telescope.pickers.entry_display'
1010

1111
local hint_pad_size = 2
1212
local content_width = 0
13+
local items_size = 0
1314
local picker_padding = 6
1415

1516
local M = {}
@@ -21,10 +22,17 @@ local flex_width = function(self, max_columns, max_lines)
2122
return width
2223
end
2324

25+
local flex_height = function(self, max_columns, max_lines)
26+
local height = items_size + picker_padding
27+
height = math.max(height, 10)
28+
height = math.min(height, math.floor(max_lines * 0.9))
29+
return height
30+
end
31+
2432
local defaults = themes.get_cursor{
2533
layout_config = {
2634
width = flex_width,
27-
height = { 0.5, min = 5, max = 24},
35+
height = flex_height,
2836
},
2937
}
3038

@@ -58,6 +66,7 @@ function picker(type, items, ctx)
5866
widths.group_name = math.max(widths.group_name, strings.strdisplaywidth(item.group_name))
5967
end
6068
content_width = widths.text + widths.hint + widths.group_name + (widths.hint > 0 and hint_pad_size or 0) + (widths.group_name > 0 and 2 or 0)
69+
items_size = #items
6170

6271
local displayer = entry_display.create {
6372
separator = ' ',

0 commit comments

Comments
 (0)