Skip to content

Commit ebc4fd2

Browse files
committed
fix: live filter overlay width calculation
1 parent 4ee6366 commit ebc4fd2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lua/nvim-tree/live-filter.lua

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

107-
local function create_overlay()
107+
local function calculate_overlay_win_width()
108+
local wininfo = vim.fn.getwininfo(view.get_winnr())[1]
109+
110+
if wininfo then
111+
return wininfo.width - wininfo.textoff - #M.prefix
112+
end
113+
108114
local min_width = 20
115+
116+
if view.View.float.enable then
117+
return min_width - 1
118+
end
119+
120+
return min_width
121+
end
122+
123+
local function create_overlay()
109124
if view.View.float.enable then
110125
-- don't close nvim-tree float when focus is changed to filter window
111126
vim.api.nvim_clear_autocmds {
112127
event = "WinLeave",
113128
pattern = "NvimTree_*",
114129
group = vim.api.nvim_create_augroup("NvimTree", { clear = false }),
115130
}
116-
117-
min_width = min_width - 2
118131
end
119132

120133
configure_buffer_overlay()
121134
overlay_winnr = vim.api.nvim_open_win(overlay_bufnr, true, {
122135
col = 1,
123136
row = 0,
124137
relative = "cursor",
125-
width = math.max(min_width, vim.api.nvim_win_get_width(view.get_winnr()) - #M.prefix - 2),
138+
width = calculate_overlay_win_width(),
126139
height = 1,
127140
border = "none",
128141
style = "minimal",

0 commit comments

Comments
 (0)