@@ -92,13 +92,15 @@ local get_padding = function(depth)
9292end
9393
9494if vim .g .lua_tree_indent_markers == 1 then
95- get_padding = function (depth , idx , tree , node , last_node )
95+ get_padding = function (depth , idx , tree , node , markers )
9696 local padding = " "
9797 if depth ~= 0 then
98- for i = 1 ,depth / 2 do
99- if idx == # tree .entries and i == depth / 2 then
98+ local rdepth = depth / 2
99+ markers [rdepth ] = idx ~= # tree .entries
100+ for i = 1 ,rdepth do
101+ if idx == # tree .entries and i == rdepth then
100102 padding = padding .. ' └ '
101- elseif not last_node or i < ( depth / 2 ) - 1 then
103+ elseif markers [ i ] then
102104 padding = padding .. ' │ '
103105 else
104106 padding = padding .. ' '
@@ -123,15 +125,15 @@ local special = {
123125 [" readme.md" ] = true ,
124126}
125127
126- local function update_draw_data (tree , depth , last_node )
128+ local function update_draw_data (tree , depth , markers )
127129 if tree .cwd and tree .cwd ~= ' /' then
128130 table.insert (lines , " .." )
129131 table.insert (hl , {' LuaTreeFolderName' , index , 0 , 2 })
130132 index = 1
131133 end
132134
133135 for idx , node in ipairs (tree .entries ) do
134- local padding = get_padding (depth , idx , tree , node , last_node )
136+ local padding = get_padding (depth , idx , tree , node , markers )
135137 local offset = string.len (padding )
136138 if depth > 0 then
137139 table.insert (hl , { ' LuaTreeIndentMarker' , index , 0 , offset })
@@ -143,7 +145,7 @@ local function update_draw_data(tree, depth, last_node)
143145 index = index + 1
144146 if node .open then
145147 table.insert (lines , padding .. icon .. node .name .. " " .. git_icon )
146- update_draw_data (node , depth + 2 , idx == # tree . entries )
148+ update_draw_data (node , depth + 2 , markers )
147149 else
148150 table.insert (lines , padding .. icon .. node .name .. " " .. git_icon )
149151 end
@@ -184,7 +186,7 @@ function M.draw(tree, reload)
184186 index = 0
185187 lines = {}
186188 hl = {}
187- update_draw_data (tree , 0 )
189+ update_draw_data (tree , 0 , {} )
188190 end
189191
190192 api .nvim_buf_set_lines (tree .bufnr , 0 , - 1 , false , lines )
0 commit comments