File tree Expand file tree Collapse file tree 4 files changed +8
-12
lines changed Expand file tree Collapse file tree 4 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ local function create_and_notify(file)
23
23
end
24
24
if M .enable_async then
25
25
async .call (vim .loop .fs_close , fd )
26
- async .schedule ()
27
26
else
28
27
vim .loop .fs_close (fd )
29
28
end
@@ -104,7 +103,6 @@ local async_fn = async.wrap(function(node)
104
103
is_error = true
105
104
break
106
105
end
107
- async .schedule ()
108
106
events ._dispatch_folder_created (new_file_path )
109
107
end
110
108
end
Original file line number Diff line number Diff line change @@ -129,7 +129,12 @@ Api.marks.navigate.next = require("nvim-tree.marks.navigation").next
129
129
Api .marks .navigate .prev = require (" nvim-tree.marks.navigation" ).prev
130
130
Api .marks .navigate .select = require (" nvim-tree.marks.navigation" ).select
131
131
132
- Api .async .call = require (" nvim-tree.async" ).call
132
+ Api .async .call = function (...)
133
+ if not require (" nvim-tree.async" ).in_async () then
134
+ error " The async call is not triggered in an async context of nvim-tree, please use `api.in_async` to detect beforehand"
135
+ end
136
+ require (" nvim-tree.async" ).call (... )
137
+ end
133
138
Api .async .in_async = require (" nvim-tree.async" ).in_async
134
139
135
140
return Api
Original file line number Diff line number Diff line change @@ -101,15 +101,6 @@ function M.schedule()
101
101
end )
102
102
end
103
103
104
- function M .unwrap_err (...)
105
- local args = { ... }
106
- local err = table.remove (args , 1 )
107
- if err then
108
- error (err )
109
- end
110
- return unpack (args )
111
- end
112
-
113
104
--- @class Interrupter
114
105
--- @field yield fun ()
115
106
--- @field interval number
Original file line number Diff line number Diff line change @@ -56,10 +56,12 @@ local function dispatch(event_name, payload)
56
56
safe_call_handlers (evt_handlers .normal )
57
57
58
58
if async .in_async () then
59
+ async .schedule () -- schedule to avoid manually calling `vim.schedule` in event handlers
59
60
safe_call_handlers (evt_handlers .async )
60
61
else
61
62
-- if we are not in async context, we should execute them in a new async context
62
63
async .exec (function ()
64
+ async .schedule ()
63
65
safe_call_handlers (evt_handlers .async )
64
66
end )
65
67
end
You can’t perform that action at this time.
0 commit comments