Skip to content

Commit 10fc0eb

Browse files
committed
sort icon only if not git signcolumn
1 parent 3af4d14 commit 10fc0eb

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lua/nvim-tree/renderer/builder.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,17 @@ function Builder:_build_line(node, idx, num_children)
248248
local git_highlight = git.get_highlight(node)
249249
local git_icons_tbl = git.get_icons(node)
250250

251-
if self.is_git_sign and git_icons_tbl and #git_icons_tbl > 0 then
252-
local git_info = git_icons_tbl[1]
253-
table.insert(self.signs, { sign = git_info.hl, lnum = self.index + 1 })
254-
git_icons_tbl = {}
251+
if git_icons_tbl and #git_icons_tbl > 0 then
252+
if self.is_git_sign then
253+
local git_info = git_icons_tbl[1]
254+
table.insert(self.signs, { sign = git_info.hl, lnum = self.index + 1 })
255+
git_icons_tbl = {}
256+
else
257+
-- sort icons so it looks slightly better
258+
table.sort(git_icons_tbl, function(a, b)
259+
return a.ord < b.ord
260+
end)
261+
end
255262
end
256263

257264
local is_folder = node.nodes ~= nil

lua/nvim-tree/renderer/components/git.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ local function get_icons_(node)
8585
end
8686
end
8787

88-
table.sort(iconss, function(a, b)
89-
return a.ord < b.ord
90-
end)
91-
9288
return iconss
9389
end
9490

0 commit comments

Comments
 (0)