Skip to content

Commit f643cdf

Browse files
authored
refactor(commons): migrate to newest async library (#256)
Co-authored-by: linrongbin16 <linrongbin16@users.noreply.github.com>
1 parent 8e193f0 commit f643cdf

File tree

9 files changed

+208
-295
lines changed

9 files changed

+208
-295
lines changed

lua/gitlinker.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ local str = require("gitlinker.commons.str")
33
local num = require("gitlinker.commons.num")
44
local LogLevels = require("gitlinker.commons.logging").LogLevels
55
local logging = require("gitlinker.commons.logging")
6+
local async = require("gitlinker.commons.async")
67

7-
local async = require("gitlinker.async")
88
local configs = require("gitlinker.configs")
99
local range = require("gitlinker.range")
1010
local linker = require("gitlinker.linker")
@@ -221,7 +221,7 @@ local _link = function(opts)
221221
lk.rev = opts.rev
222222
end
223223

224-
async.scheduler()
224+
async.schedule()
225225
local ok, url = pcall(opts.router, lk, true)
226226
-- logger:debug(
227227
-- "|link| ok:%s, url:%s, router:%s",
@@ -273,7 +273,7 @@ local _link = function(opts)
273273
end
274274

275275
--- @type fun(opts:{action:gitlinker.Action?,router:gitlinker.Router,lstart:integer,lend:integer,remote:string?,file:string?,rev:string?}):string?
276-
local _void_link = async.void(_link)
276+
local _sync_link = async.sync(1, _link)
277277

278278
--- @param args string?
279279
--- @return {router_type:string,remote:string?,file:string?,rev:string?}
@@ -332,7 +332,7 @@ local function setup(opts)
332332
local lstart = math.min(r.lstart, r.lend, command_opts.line1, command_opts.line2)
333333
local lend = math.max(r.lstart, r.lend, command_opts.line1, command_opts.line2)
334334
local parsed = _parse_args(args)
335-
_void_link({
335+
_sync_link({
336336
action = command_opts.bang and require("gitlinker.actions").system
337337
or require("gitlinker.actions").clipboard,
338338
router = function(lk)
@@ -392,7 +392,7 @@ local function link_api(opts)
392392
opts.lend = math.max(r.lstart, r.lend)
393393
end
394394

395-
_void_link({
395+
_sync_link({
396396
action = opts.action,
397397
router = opts.router,
398398
lstart = opts.lstart,
@@ -408,7 +408,7 @@ end
408408
local M = {
409409
_url_template_engine = _url_template_engine,
410410
_worker = _worker,
411-
_void_link = _void_link,
411+
_sync_link = _sync_link,
412412
_router = _router,
413413
_browse = _browse,
414414
_blame = _blame,

lua/gitlinker/async.lua

Lines changed: 0 additions & 277 deletions
This file was deleted.

0 commit comments

Comments
 (0)