@@ -12,6 +12,28 @@ local function hide(win)
12
12
end
13
13
end
14
14
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
+
15
37
local function show ()
16
38
local line_nr = api .nvim_win_get_cursor (0 )[1 ]
17
39
if line_nr == 1 and require (" nvim-tree.view" ).is_root_folder_visible () then
@@ -32,14 +54,17 @@ local function show()
32
54
return
33
55
end
34
56
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
37
61
return
38
62
end
63
+
39
64
M .popup_win = api .nvim_open_win (api .nvim_create_buf (false , false ), false , {
40
65
relative = " win" ,
41
66
bufpos = { fn .line " ." - 2 , 0 },
42
- width = math.min (width , vim .o .columns - 2 ),
67
+ width = math.min (text_width , vim .o .columns - 2 ),
43
68
height = 1 ,
44
69
noautocmd = true ,
45
70
style = " minimal" ,
0 commit comments