@@ -92,13 +92,15 @@ local get_padding = function(depth)
92
92
end
93
93
94
94
if 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 )
96
96
local padding = " "
97
97
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
100
102
padding = padding .. ' └ '
101
- elseif not last_node or i < ( depth / 2 ) - 1 then
103
+ elseif markers [ i ] then
102
104
padding = padding .. ' │ '
103
105
else
104
106
padding = padding .. ' '
@@ -123,15 +125,15 @@ local special = {
123
125
[" readme.md" ] = true ,
124
126
}
125
127
126
- local function update_draw_data (tree , depth , last_node )
128
+ local function update_draw_data (tree , depth , markers )
127
129
if tree .cwd and tree .cwd ~= ' /' then
128
130
table.insert (lines , " .." )
129
131
table.insert (hl , {' LuaTreeFolderName' , index , 0 , 2 })
130
132
index = 1
131
133
end
132
134
133
135
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 )
135
137
local offset = string.len (padding )
136
138
if depth > 0 then
137
139
table.insert (hl , { ' LuaTreeIndentMarker' , index , 0 , offset })
@@ -143,7 +145,7 @@ local function update_draw_data(tree, depth, last_node)
143
145
index = index + 1
144
146
if node .open then
145
147
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 )
147
149
else
148
150
table.insert (lines , padding .. icon .. node .name .. " " .. git_icon )
149
151
end
@@ -184,7 +186,7 @@ function M.draw(tree, reload)
184
186
index = 0
185
187
lines = {}
186
188
hl = {}
187
- update_draw_data (tree , 0 )
189
+ update_draw_data (tree , 0 , {} )
188
190
end
189
191
190
192
api .nvim_buf_set_lines (tree .bufnr , 0 , - 1 , false , lines )
0 commit comments