@@ -147,7 +147,7 @@ function win:get_border_size(border)
147
147
if border == ' none' then
148
148
return { vertical = 0 , horizontal = 0 , left = 0 , right = 0 , top = 0 , bottom = 0 }
149
149
elseif border == ' padded' then
150
- return { vertical = 0 , horizontal = 1 , left = 1 , right = 0 , top = 0 , bottom = 0 }
150
+ return { vertical = 0 , horizontal = 2 , left = 1 , right = 1 , top = 0 , bottom = 0 }
151
151
elseif border == ' shadow' then
152
152
return { vertical = 1 , horizontal = 1 , left = 0 , right = 1 , top = 0 , bottom = 1 }
153
153
elseif type (border ) == ' string' then
@@ -225,7 +225,7 @@ function win:get_vertical_direction_and_height(direction_priority)
225
225
local direction_priority_by_space = vim .fn .sort (vim .deepcopy (direction_priority ), function (a , b )
226
226
local distance_a = math.min (max_height , get_distance (a ))
227
227
local distance_b = math.min (max_height , get_distance (b ))
228
- return distance_a < distance_b
228
+ return distance_a < distance_b and - 1 or distance_a > distance_b and 1 or 0
229
229
end )
230
230
231
231
local direction = direction_priority_by_space [1 ]
237
237
function win :get_direction_with_window_constraints (anchor_win , direction_priority )
238
238
local cursor_constraints = self .get_cursor_screen_position ()
239
239
local anchor_config = vim .fn .screenpos (anchor_win :get_win (), 1 , 1 )
240
- local anchor_border_size = self :get_border_size (anchor_config . border )
240
+ local anchor_border_size = anchor_win :get_border_size ()
241
241
local anchor_col = anchor_config .col - anchor_border_size .left
242
242
local anchor_row = anchor_config .row - anchor_border_size .top
243
243
local anchor_height = anchor_win :get_height ()
@@ -254,17 +254,17 @@ function win:get_direction_with_window_constraints(anchor_win, direction_priorit
254
254
local direction_constraints = {
255
255
n = {
256
256
vertical = anchor_is_above_cursor and (anchor_row - 1 ) or cursor_constraints .distance_from_top ,
257
- horizontal = screen_width - anchor_col + 1 ,
257
+ horizontal = screen_width - ( anchor_col - 1 ) ,
258
258
},
259
259
s = {
260
260
vertical = anchor_is_above_cursor and cursor_constraints .distance_from_bottom
261
261
or (screen_height - (anchor_height + anchor_row - 1 )),
262
- horizontal = screen_width - anchor_col + 1 ,
262
+ horizontal = screen_width - ( anchor_col - 1 ) ,
263
263
},
264
264
e = {
265
265
vertical = anchor_is_above_cursor and cursor_constraints .distance_from_top
266
266
or cursor_constraints .distance_from_bottom ,
267
- horizontal = screen_width - (anchor_col + anchor_width - 1 ),
267
+ horizontal = screen_width - (anchor_col - 1 ) - anchor_width ,
268
268
},
269
269
w = {
270
270
vertical = anchor_is_above_cursor and cursor_constraints .distance_from_top
@@ -280,7 +280,7 @@ function win:get_direction_with_window_constraints(anchor_win, direction_priorit
280
280
local constraints_b = direction_constraints [b ]
281
281
local distance_a = math.min (max_height , constraints_a .vertical , constraints_a .horizontal )
282
282
local distance_b = math.min (max_height , constraints_b .vertical , constraints_b .horizontal )
283
- return distance_a < distance_b
283
+ return distance_a < distance_b and - 1 or distance_a > distance_b and 1 or 0
284
284
end )
285
285
286
286
local border_size = self :get_border_size ()
0 commit comments