From 44df136b3c9e5a0723448f75f0024dee39b19e14 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 3 Apr 2026 10:42:17 +0800 Subject: [PATCH 1/4] test timeout --- lua/gitlinker.lua | 2 +- lua/gitlinker/git.lua | 5 +++++ lua/gitlinker/util.lua | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/gitlinker.lua b/lua/gitlinker.lua index 7deba95..1ca7ec0 100644 --- a/lua/gitlinker.lua +++ b/lua/gitlinker.lua @@ -199,7 +199,7 @@ end --- @return string? local _link = function(opts) local confs = configs.get() - log.debug(string.format("|link| opts:%s, confs:%s", vim.inspect(opts), vim.inspect(confs))) + -- log.debug(string.format("|link| opts:%s, confs:%s", vim.inspect(opts), vim.inspect(confs))) local lk = linker.make_linker(opts.remote, opts.file, opts.rev, confs.timeout_ms, confs.max_parent_commits) diff --git a/lua/gitlinker/git.lua b/lua/gitlinker/git.lua index b7d62d6..bf97f45 100644 --- a/lua/gitlinker/git.lua +++ b/lua/gitlinker/git.lua @@ -51,6 +51,11 @@ local function _run_cmd_async(args, cwd, callback) --- @param completed vim.SystemCompleted local function on_exit(completed) + local j = 0 + for i = 1, 1000000000 do + j = j + i + end + log.debug(string.format("j:%d", j)) local result = CmdResult:new() if str.not_blank(completed.stdout) then result.stdout = str.split(str.trim(completed.stdout), "\n", { trimempty = true }) diff --git a/lua/gitlinker/util.lua b/lua/gitlinker/util.lua index 603a263..6385c18 100644 --- a/lua/gitlinker/util.lua +++ b/lua/gitlinker/util.lua @@ -47,13 +47,15 @@ end --- @return boolean local function is_timeout(start_at, timeout_ms) local now = now_milliseconds() - local yes = type(timeout_ms) == "number" and now_milliseconds() - start_at >= timeout_ms + local diff = type(timeout_ms) == "number" and (now - start_at) or -1 + local yes = type(timeout_ms) == "number" and (now - start_at >= timeout_ms) log.debug( string.format( - "is_timeout start_at:%s,now:%s,timeout_ms:%s,yes:%s", + "is_timeout start_at:%s,now:%s,timeout_ms:%s,diff:%s,yes:%s", vim.inspect(start_at), vim.inspect(now), vim.inspect(timeout_ms), + vim.inspect(diff), vim.inspect(yes) ) ) From a3f60e7d9a019bac7baeb54ecb1bce8d2964fc25 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 3 Apr 2026 10:47:00 +0800 Subject: [PATCH 2/4] c --- lua/gitlinker/git.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/gitlinker/git.lua b/lua/gitlinker/git.lua index bf97f45..99da7b1 100644 --- a/lua/gitlinker/git.lua +++ b/lua/gitlinker/git.lua @@ -51,8 +51,9 @@ local function _run_cmd_async(args, cwd, callback) --- @param completed vim.SystemCompleted local function on_exit(completed) + local n = math.floor(math.random(1000000, 1000000000)) local j = 0 - for i = 1, 1000000000 do + for i = 1, n do j = j + i end log.debug(string.format("j:%d", j)) From 386af71a4a8014566d623eaa79f4000c70ceaf4b Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 3 Apr 2026 10:47:38 +0800 Subject: [PATCH 3/4] c --- lua/gitlinker/git.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gitlinker/git.lua b/lua/gitlinker/git.lua index 99da7b1..d7939cc 100644 --- a/lua/gitlinker/git.lua +++ b/lua/gitlinker/git.lua @@ -51,7 +51,7 @@ local function _run_cmd_async(args, cwd, callback) --- @param completed vim.SystemCompleted local function on_exit(completed) - local n = math.floor(math.random(1000000, 1000000000)) + local n = 100000000 local j = 0 for i = 1, n do j = j + i From 5ec8f09394c2b1e38221d1d64837952d7ccc46af Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 3 Apr 2026 10:48:07 +0800 Subject: [PATCH 4/4] c --- lua/gitlinker/git.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gitlinker/git.lua b/lua/gitlinker/git.lua index d7939cc..a618a53 100644 --- a/lua/gitlinker/git.lua +++ b/lua/gitlinker/git.lua @@ -51,7 +51,7 @@ local function _run_cmd_async(args, cwd, callback) --- @param completed vim.SystemCompleted local function on_exit(completed) - local n = 100000000 + local n = 200000000 local j = 0 for i = 1, n do j = j + i