Skip to content

Commit 95ed588

Browse files
committed
fix(#549): add more profiling ~tree init
1 parent 899ed45 commit 95ed588

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Diff for: lua/nvim-tree/core.lua

+5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ local events = require "nvim-tree.events"
22
local explorer = require "nvim-tree.explorer"
33
local live_filter = require "nvim-tree.live-filter"
44
local view = require "nvim-tree.view"
5+
local log = require "nvim-tree.log"
56

67
local M = {}
78

89
TreeExplorer = nil
910
local first_init_done = false
1011

1112
function M.init(foldername)
13+
local pn = string.format("core init %s", foldername)
14+
local ps = log.profile_start(pn)
15+
1216
if TreeExplorer then
1317
TreeExplorer:destroy()
1418
end
@@ -17,6 +21,7 @@ function M.init(foldername)
1721
events._dispatch_ready()
1822
first_init_done = true
1923
end
24+
log.profile_end(ps, pn)
2025
end
2126

2227
function M.get_explorer()

Diff for: lua/nvim-tree/explorer/explore.lua

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local sorters = require "nvim-tree.explorer.sorters"
55
local filters = require "nvim-tree.explorer.filters"
66
local live_filter = require "nvim-tree.live-filter"
77
local notify = require "nvim-tree.notify"
8+
local log = require "nvim-tree.log"
89

910
local M = {}
1011

@@ -61,6 +62,9 @@ function M.explore(node, status)
6162
return
6263
end
6364

65+
local pn = string.format("explore init %s", node.absolute_path)
66+
local ps = log.profile_start(pn)
67+
6468
populate_children(handle, cwd, node, status)
6569

6670
local is_root = not node.parent
@@ -69,11 +73,15 @@ function M.explore(node, status)
6973
node.group_next = child_folder_only
7074
local ns = M.explore(child_folder_only, status)
7175
node.nodes = ns or {}
76+
77+
log.profile_end(ps, pn)
7278
return ns
7379
end
7480

7581
sorters.merge_sort(node.nodes, sorters.node_comparator)
7682
live_filter.apply_filter(node)
83+
84+
log.profile_end(ps, pn)
7785
return node.nodes
7886
end
7987

Diff for: lua/nvim-tree/view.lua

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local M = {}
22

33
local events = require "nvim-tree.events"
44
local utils = require "nvim-tree.utils"
5+
local log = require "nvim-tree.log"
56

67
local function get_win_sep_hl()
78
-- #1221 WinSeparator not present in nvim 0.6.1 and some builds of 0.7.0
@@ -231,6 +232,9 @@ function M.open(options)
231232
return
232233
end
233234

235+
local pn = string.format "view open"
236+
local ps = log.profile_start(pn)
237+
234238
create_buffer()
235239
open_window()
236240
M.resize()
@@ -240,6 +244,8 @@ function M.open(options)
240244
vim.cmd "wincmd p"
241245
end
242246
events._dispatch_on_tree_open()
247+
248+
log.profile_end(ps, pn)
243249
end
244250

245251
local function grow()

0 commit comments

Comments
 (0)