Skip to content

Commit 5bde916

Browse files
authored
fix(selector): selector layouts cannot handle when not enough width (#1392)
1 parent 230e938 commit 5bde916

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

lua/neo-tree/ui/selector.lua

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,11 @@ M.get_selector = function(state, width)
292292
local trunc_char = config.source_selector.truncation_character or ""
293293
local remaining_width = width - length_separators
294294
local return_string = text_with_hl(add_padding(padding.left), hl_background)
295-
if width < length_sum and config.source_selector.text_trunc_to_fit then -- not enough width
296-
local each_width = math.floor(remaining_width / #tabs)
297-
local remaining = remaining_width % each_width
298-
tabs_layout = "start"
299-
length_sum = width
300-
for _, tab in ipairs(tabs) do
301-
tab.text = text_layout( -- truncate text and pass it to "start"
302-
tab.text,
303-
"center",
304-
each_width + (tab.is_active and remaining or 0),
305-
trunc_char
306-
)
307-
end
295+
if width < length_sum then -- not enough width
296+
tabs_layout = "equal" -- other methods cannot handle this
308297
end
309298
if tabs_layout == "active" then
310-
local active_tab_length = width - length_sum + length_active
299+
local active_tab_length = width - length_sum + length_active - 1
311300
for _, tab in ipairs(tabs) do
312301
return_string = return_string
313302
.. render_tab(

0 commit comments

Comments
 (0)