Skip to content

Commit fba9751

Browse files
authored
fix(#1679): renderer.full_name correctly shows for one character outside (#1688)
ref: `:h getwininfo()` Signed-off-by: Sabu Siyad <hello@ssiyad.com> Signed-off-by: Sabu Siyad <hello@ssiyad.com>
1 parent 1044eba commit fba9751

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

lua/nvim-tree/renderer/components/full-name.lua

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ local function hide(win)
1212
end
1313
end
1414

15+
-- reduce signcolumn/foldcolumn from window width
16+
local function effective_win_width()
17+
local win_width = fn.winwidth(0)
18+
19+
-- return zero if the window cannot be found
20+
local win_id = fn.win_getid()
21+
22+
if win_id == 0 then
23+
return win_width
24+
end
25+
26+
-- if the window does not exist the result is an empty list
27+
local win_info = fn.getwininfo(win_id)
28+
29+
-- check if result table is empty
30+
if next(win_info) == nil then
31+
return win_width
32+
end
33+
34+
return win_width - win_info[1].textoff
35+
end
36+
1537
local function show()
1638
local line_nr = api.nvim_win_get_cursor(0)[1]
1739
if line_nr == 1 and require("nvim-tree.view").is_root_folder_visible() then
@@ -32,14 +54,17 @@ local function show()
3254
return
3355
end
3456

35-
local width = fn.strdisplaywidth(fn.substitute(line, "[^[:print:]]*$", "", "g"))
36-
if width < fn.winwidth(0) then
57+
local text_width = fn.strdisplaywidth(fn.substitute(line, "[^[:print:]]*$", "", "g"))
58+
local win_width = effective_win_width()
59+
60+
if text_width < win_width then
3761
return
3862
end
63+
3964
M.popup_win = api.nvim_open_win(api.nvim_create_buf(false, false), false, {
4065
relative = "win",
4166
bufpos = { fn.line "." - 2, 0 },
42-
width = math.min(width, vim.o.columns - 2),
67+
width = math.min(text_width, vim.o.columns - 2),
4368
height = 1,
4469
noautocmd = true,
4570
style = "minimal",

0 commit comments

Comments
 (0)