@@ -35,20 +35,25 @@ local diag_severity_to_string = function(severity)
3535end
3636
3737local tracked_functions = {}
38+ --- @enum NeotreeDebounceStrategy
3839M .debounce_strategy = {
3940 CALL_FIRST_AND_LAST = 0 ,
4041 CALL_LAST_ONLY = 1 ,
4142}
4243
44+ --- @enum NeotreeDebounceAction
4345M .debounce_action = {
4446 START_NORMAL = 0 ,
4547 START_ASYNC_JOB = 1 ,
4648 COMPLETE_ASYNC_JOB = 2 ,
4749}
4850
49- local defer_function
50- -- Part of debounce. Moved out of the function to eliminate memory leaks.
51- defer_function = function (id , frequency_in_ms , strategy , action )
51+ --- Part of debounce. Moved out of the function to eliminate memory leaks.
52+ --- @param id string Identifier for the debounce group , such as the function name.
53+ --- @param frequency_in_ms number Miniumum amount of time between invocations of fn.
54+ --- @param strategy NeotreeDebounceStrategy The debounce_strategy to use , determines which calls to fn are not dropped.
55+ --- @param action NeotreeDebounceAction ? The debounce_action to use , determines how the function is invoked
56+ local function defer_function (id , frequency_in_ms , strategy , action )
5257 tracked_functions [id ].in_debounce_period = true
5358 vim .defer_fn (function ()
5459 local current_data = tracked_functions [id ]
7277--- @param id string Identifier for the debounce group , such as the function name.
7378--- @param fn function Function to be executed.
7479--- @param frequency_in_ms number Miniumum amount of time between invocations of fn.
75- --- @param strategy number The debounce_strategy to use , determines which calls to fn are not dropped.
80+ --- @param strategy NeotreeDebounceStrategy The debounce_strategy to use , determines which calls to fn are not dropped.
81+ --- @param action NeotreeDebounceAction ? The debounce_action to use , determines how the function is invoked
7682M .debounce = function (id , fn , frequency_in_ms , strategy , action )
7783 local fn_data = tracked_functions [id ]
7884
@@ -119,8 +125,8 @@ M.debounce = function(id, fn, frequency_in_ms, strategy, action)
119125 if type (fn ) == " function" then
120126 success , result = pcall (fn )
121127 end
122- fn_data .fn = nil
123128 fn = nil
129+ fn_data .fn = fn
124130
125131 if not success then
126132 log .error (" debounce " , id , " error: " , result )
208214--- Converts a filesize from libuv.stats into a human readable string with appropriate units.
209215--- @param size any
210216--- @return string
211- M .human_size = function (size )
217+ M .human_size = function (size )
212218 local human = filesize (size , { output = " string" })
213219 --- @cast human string
214220 return human
@@ -355,12 +361,12 @@ M.get_inner_win_width = function(winid)
355361end
356362
357363local stat_providers = {
358- default = function (node )
364+ default = function (node )
359365 return vim .loop .fs_stat (node .path )
360366 end ,
361367}
362368
363- --- Gets the statics for a node in the file system. The `stat` object will be cached
369+ --- Gets the statics for a node in the file system. The `stat` object will be cached
364370--- for the lifetime of the node.
365371---
366372--- @param node table The Nui TreeNode node to get the stats for.
@@ -373,7 +379,7 @@ local stat_providers = {
373379--- @field birthtime StatTime
374380--- @field mtime StatTime
375381--- @field size number
376- M .get_stat = function (node )
382+ M .get_stat = function (node )
377383 if node .stat == nil then
378384 local provider = stat_providers [node .stat_provider or " default" ]
379385 local success , stat = pcall (provider , node )
385391--- Register a function to provide stats for a node.
386392--- @param name string The name of the stat provider.
387393--- @param func function The function to call to get the stats.
388- M .register_stat_provider = function (name , func )
394+ M .register_stat_provider = function (name , func )
389395 stat_providers [name ] = func
390396 log .debug (" Registered stat provider" , name )
391397end
632638--- @param bufnr number | nil The buffer number to open
633639M .open_file = function (state , path , open_cmd , bufnr )
634640 open_cmd = open_cmd or " edit"
635- -- If the file is already open, switch to it.
641+ -- If the file is already open, switch to it.
636642 bufnr = bufnr or M .find_buffer_by_name (path )
637643 if bufnr <= 0 then
638644 bufnr = nil
0 commit comments