File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,9 @@ cmp.confirm = function(option, callback)
175
175
return true
176
176
end
177
177
178
- cmp .core .filter .raw (cmp .core )
178
+ vim .wait (1000 , function ()
179
+ return not cmp .core .filter .running
180
+ end )
179
181
local e = cmp .core .view :get_selected_entry () or (option .select and cmp .core .view :get_first_entry () or nil )
180
182
if e then
181
183
cmp .core :confirm (e , {
Original file line number Diff line number Diff line change 1
1
local async = {}
2
2
3
3
--- @class cmp.AsyncThrottle
4
+ --- @field public running boolean
4
5
--- @field public timeout number
5
6
--- @field public stop function
6
- --- @field public raw function
7
7
--- @field public __call function
8
8
9
9
--- @param fn function
@@ -18,29 +18,23 @@ async.throttle = function(fn, timeout)
18
18
stop = function ()
19
19
time = nil
20
20
timer :stop ()
21
- end ,
22
- raw = function (...)
23
- fn (... )
24
- end ,
21
+ end
25
22
}, {
26
23
__call = function (self , ...)
27
24
local args = { ... }
28
25
29
26
if time == nil then
30
27
time = vim .loop .now ()
31
28
end
32
- timer :stop ()
33
29
34
- local delta = math.max (1 , self .timeout - (vim .loop .now () - time ))
35
- timer :start (delta , 0 , function ()
36
- if not self .running then
30
+ self .running = true
31
+ timer :stop ()
32
+ timer :start (math.max (1 , self .timeout - (vim .loop .now () - time )), 0 , function ()
33
+ vim .schedule (function ()
37
34
time = nil
38
- self .running = true
39
- vim .schedule (function ()
40
- self .running = false
41
- fn (unpack (args ))
42
- end )
43
- end
35
+ self .running = false
36
+ fn (unpack (args ))
37
+ end )
44
38
end )
45
39
end ,
46
40
})
You can’t perform that action at this time.
0 commit comments