Skip to content

Commit 80cfead

Browse files
fix(#2523): live filter overlay width calculation (#2524)
* fix: live filter overlay width calculation * refactor: simplify calculate_width return if not wininfo --------- Co-authored-by: Alexander Courtis <[email protected]>
1 parent 874ae6e commit 80cfead

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lua/nvim-tree/live-filter.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,32 @@ local function configure_buffer_overlay()
105105
vim.api.nvim_buf_set_keymap(overlay_bufnr, "i", "<CR>", "<cmd>stopinsert<CR>", {})
106106
end
107107

108+
local function calculate_overlay_win_width()
109+
local wininfo = vim.fn.getwininfo(view.get_winnr())[1]
110+
111+
if wininfo then
112+
return wininfo.width - wininfo.textoff - #M.prefix
113+
end
114+
115+
return 20
116+
end
117+
108118
local function create_overlay()
109-
local min_width = 20
110119
if view.View.float.enable then
111120
-- don't close nvim-tree float when focus is changed to filter window
112121
vim.api.nvim_clear_autocmds {
113122
event = "WinLeave",
114123
pattern = "NvimTree_*",
115124
group = vim.api.nvim_create_augroup("NvimTree", { clear = false }),
116125
}
117-
118-
min_width = min_width - 2
119126
end
120127

121128
configure_buffer_overlay()
122129
overlay_winnr = vim.api.nvim_open_win(overlay_bufnr, true, {
123130
col = 1,
124131
row = 0,
125132
relative = "cursor",
126-
width = math.max(min_width, vim.api.nvim_win_get_width(view.get_winnr()) - #M.prefix - 2),
133+
width = calculate_overlay_win_width(),
127134
height = 1,
128135
border = "none",
129136
style = "minimal",

0 commit comments

Comments
 (0)