@@ -51,14 +51,13 @@ local function show(opts)
51
51
end
52
52
53
53
local text_width = vim .fn .strdisplaywidth (vim .fn .substitute (line , " [^[:print:]]*$" , " " , " g" ))
54
+ local win_width = effective_win_width ()
54
55
55
- -- also make space for right- aligned icons
56
+ -- windows width reduced by right aligned icons
56
57
local icon_ns_id = vim .api .nvim_get_namespaces ()[" NvimTreeExtmarks" ]
57
58
local icon_extmarks = vim .api .nvim_buf_get_extmarks (0 , icon_ns_id , { line_nr - 1 , 0 }, { line_nr - 1 , - 1 }, { details = true })
58
59
text_width = text_width + view .extmarks_length (icon_extmarks )
59
60
60
- local win_width = effective_win_width ()
61
-
62
61
if text_width < win_width then
63
62
return
64
63
end
@@ -75,24 +74,11 @@ local function show(opts)
75
74
})
76
75
vim .wo [M .popup_win ].winhl = view .View .winopts .winhl
77
76
78
- local hl_ns_id = vim .api .nvim_get_namespaces ()[" NvimTreeHighlights" ]
79
- local hl_extmarks = vim .api .nvim_buf_get_extmarks (0 , hl_ns_id , { line_nr - 1 , 0 }, { line_nr - 1 , - 1 }, { details = true })
77
+ local ns_id = vim .api .nvim_get_namespaces ()[" NvimTreeHighlights" ]
78
+ local extmarks = vim .api .nvim_buf_get_extmarks (0 , ns_id , { line_nr - 1 , 0 }, { line_nr - 1 , - 1 }, { details = true })
80
79
vim .api .nvim_win_call (M .popup_win , function ()
81
80
vim .api .nvim_buf_set_lines (0 , 0 , - 1 , true , { line })
82
-
83
- -- copy also right-aligned icons
84
- for _ , extmark in ipairs (icon_extmarks ) do
85
- local details = extmark [4 ]
86
- if details then
87
- vim .api .nvim_buf_set_extmark (0 , icon_ns_id , 0 , 0 , {
88
- virt_text = details .virt_text ,
89
- virt_text_pos = details .virt_text_pos ,
90
- hl_mode = details .hl_mode ,
91
- })
92
- end
93
- end
94
-
95
- for _ , extmark in ipairs (hl_extmarks ) do
81
+ for _ , extmark in ipairs (extmarks ) do
96
82
-- nvim 0.10 luadoc is incorrect: vim.api.keyset.get_extmark_item is missing the extmark_id at the start
97
83
98
84
--- @cast extmark table
@@ -103,9 +89,9 @@ local function show(opts)
103
89
104
90
if type (details ) == " table" then
105
91
if vim .fn .has (" nvim-0.11" ) == 1 and vim .hl and vim .hl .range then
106
- vim .hl .range (0 , hl_ns_id , details .hl_group , { 0 , col }, { 0 , details .end_col , }, {})
92
+ vim .hl .range (0 , ns_id , details .hl_group , { 0 , col }, { 0 , details .end_col , }, {})
107
93
else
108
- vim .api .nvim_buf_add_highlight (0 , hl_ns_id , details .hl_group , 0 , col , details .end_col ) --- @diagnostic disable-line : deprecated
94
+ vim .api .nvim_buf_add_highlight (0 , ns_id , details .hl_group , 0 , col , details .end_col ) --- @diagnostic disable-line : deprecated
109
95
end
110
96
end
111
97
end
0 commit comments