@@ -383,9 +383,12 @@ local function calculate_window_size(items, opts, formatter)
383
383
local row_position = opts .row_position
384
384
local lines = vim .o .lines
385
385
local max_available_height
386
- if row_position == " top10" or row_position == " top10_right" then
387
- max_available_height = lines - math.floor (lines * 0.1 ) - vim .o .cmdheight - 4
388
- elseif row_position == " bottom" then
386
+ local position_info = parse_position (row_position )
387
+
388
+ if position_info .type :match (" ^top" ) then
389
+ -- Handle any top position (top, top_right, with any percentage)
390
+ max_available_height = lines - math.floor (lines * position_info .ratio ) - vim .o .cmdheight - 4
391
+ elseif position_info .type == " bottom" then
389
392
max_available_height = math.floor (vim .o .lines * 0.2 )
390
393
else
391
394
max_available_height = lines - math.floor (lines / 2 ) - 4
@@ -748,22 +751,20 @@ local function resize_window(state, opts)
748
751
if not (state .active and vim .api .nvim_win_is_valid (state .win )) then
749
752
return
750
753
end
751
-
752
754
-- Calculate new dimensions based on filtered items
753
755
local new_width , new_height = calculate_window_size (state .filtered_items , opts , opts .formatter )
754
-
755
- -- Get current window config
756
756
local current_config = vim .api .nvim_win_get_config (state .win )
757
-
758
757
-- Calculate maximum height based on available space below the initial row
759
758
local max_available_height
760
- if opts .row_position == " top10" or M .config .row_position == " top10" then
761
- max_available_height = vim .o .lines - math.floor (vim .o .lines * 0.1 ) - vim .o .cmdheight - 4 -- Leave some space for status line
759
+ local row_position = opts .row_position or M .config .row_position
760
+ local position_info = parse_position (row_position )
761
+ if position_info .type :match (" ^top" ) then
762
+ -- Handle any top position (top, top_right, with any percentage)
763
+ max_available_height = vim .o .lines - math.floor (vim .o .lines * position_info .ratio ) - vim .o .cmdheight - 4
762
764
else
763
765
max_available_height = vim .o .lines - state .row - vim .o .cmdheight - 4 -- Leave some space for status line
764
766
end
765
767
new_height = math.min (new_height , max_available_height )
766
-
767
768
-- print(
768
769
-- string.format(
769
770
-- "Resizing window: row=%d, col=%d, width=%d, height=%d, max_available_height=%d, num_items=%d",
0 commit comments