Skip to content

Commit b5143e5

Browse files
committed
fix(files): take border into account when computing maximum window width
1 parent a68921e commit b5143e5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lua/mini/files.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,22 +2448,23 @@ H.window_open = function(buf_id, config)
24482448
end
24492449

24502450
H.window_update = function(win_id, config)
2451+
-- Preserve some config values
2452+
local win_config = vim.api.nvim_win_get_config(win_id)
2453+
config.border, config.title_pos = win_config.border, win_config.title_pos
2454+
24512455
-- Compute helper data
24522456
local has_tabline = vim.o.showtabline == 2 or (vim.o.showtabline == 1 and #vim.api.nvim_list_tabpages() > 1)
24532457
local max_height = H.window_get_max_height()
2458+
local max_width = vim.o.columns - (config.border == 'none' and 0 or 2)
24542459

24552460
-- Ensure proper fit
24562461
config.row = has_tabline and 1 or 0
24572462
config.height = config.height ~= nil and math.min(config.height, max_height) or nil
2458-
config.width = config.width ~= nil and math.min(config.width, vim.o.columns) or nil
2463+
config.width = config.width ~= nil and math.min(config.width, max_width) or nil
24592464

24602465
-- Ensure proper title
24612466
if type(config.title) == 'string' then config.title = H.fit_to_width(config.title, config.width) end
24622467

2463-
-- Preserve some config values
2464-
local win_config = vim.api.nvim_win_get_config(win_id)
2465-
config.border, config.title_pos = win_config.border, win_config.title_pos
2466-
24672468
-- Update config
24682469
config.relative = 'editor'
24692470
vim.api.nvim_win_set_config(win_id, config)

tests/screenshots/tests-test_files.lua---Windows---works-with-too-small-dimensions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-|---------|-----
2-
1|┌…-files/commo
2+
1|┌…iles/common
33
2|│ .a-dir │
44
3|│ a-dir │
55
4|│ b-dir │

0 commit comments

Comments
 (0)