Skip to content

Commit f1f3306

Browse files
authored
fix: account for signs/line numbers in auto_expand_width (#1766)
1 parent 70ebc41 commit f1f3306

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lua/neo-tree/ui/renderer.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,11 +1149,13 @@ render_tree = function(state)
11491149
state.tree:render()
11501150
end
11511151
state._in_pre_render = false
1152+
local textoffset = vim.fn.getwininfo(state.winid)[1].textoff or 0
1153+
local desired_width = state.longest_node + textoffset
11521154
state.window.last_user_width = vim.api.nvim_win_get_width(state.winid)
1153-
if should_auto_expand and state.longest_node > state.window.last_user_width then
1155+
if should_auto_expand and desired_width > state.window.last_user_width then
11541156
log.trace(string.format("auto_expand_width: on. Expanding width to %s.", state.longest_node))
1155-
vim.api.nvim_win_set_width(state.winid, state.longest_node)
1156-
state.win_width = state.longest_node
1157+
vim.api.nvim_win_set_width(state.winid, desired_width)
1158+
state.win_width = desired_width
11571159
end
11581160
end
11591161
if M.tree_is_visible(state) then

0 commit comments

Comments
 (0)