summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-02-09 13:16:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-02-09 13:16:37 +0800
commit7321df77c443853370cbb10acd619a0073c55a13 (patch)
tree064917ead0c6df3ae4a70f32fc301122362cbeeb /script
parentcea9695fd73b6d78093cba1e1eff468a2227ac79 (diff)
downloadlua-language-server-7321df77c443853370cbb10acd619a0073c55a13.zip
use `time.time` instead of `os.clock`
the implementation of os.clock under the windows platform is inconsistent with other platforms
Diffstat (limited to 'script')
-rw-r--r--script/progress.lua13
-rw-r--r--script/provider/diagnostic.lua7
2 files changed, 11 insertions, 9 deletions
diff --git a/script/progress.lua b/script/progress.lua
index d5c174ce..3165820d 100644
--- a/script/progress.lua
+++ b/script/progress.lua
@@ -2,6 +2,7 @@ local proto = require 'proto.proto'
local util = require 'utility'
local timer = require "timer"
local config = require 'config'
+local time = require 'bee.time'
local nextToken = util.counter()
@@ -81,8 +82,8 @@ function mt:_update()
return
end
if not self._showed
- and self._clock + self._delay <= os.clock() then
- self._updated = os.clock()
+ and self._clock + self._delay <= time.time() then
+ self._updated = time.time()
self._dirty = false
if not config.get(self._scp.uri, 'Lua.window.progressBar') then
return
@@ -111,11 +112,11 @@ function mt:_update()
self:remove()
return
end
- if os.clock() - self._updated < 0.05 then
+ if time.time() - self._updated < 0.05 then
return
end
self._dirty = false
- self._updated = os.clock()
+ self._updated = time.time()
proto.notify('$/progress', {
token = self._token,
value = {
@@ -151,8 +152,8 @@ function m.create(scp, title, delay)
local prog = setmetatable({
_token = nextToken(),
_title = title,
- _clock = os.clock(),
- _delay = delay,
+ _clock = time.time(),
+ _delay = delay * 1000,
_scp = scp,
}, mt)
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 209e2aaa..d0de0962 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -12,6 +12,7 @@ local client = require 'client'
local converter = require 'proto.converter'
local loading = require 'workspace.loading'
local scope = require 'workspace.scope'
+local time = require 'bee.time'
---@class diagnosticProvider
local m = {}
@@ -260,13 +261,13 @@ function m.doDiagnostic(uri, isScopeDiag)
pushResult()
- local lastPushClock = os.clock()
+ local lastPushClock = time.time()
---@async
xpcall(core, log.error, uri, isScopeDiag, function (result)
diags[#diags+1] = buildDiagnostic(uri, result)
- if not isScopeDiag and os.clock() - lastPushClock >= 0.2 then
- lastPushClock = os.clock()
+ if not isScopeDiag and time.time() - lastPushClock >= 200 then
+ lastPushClock = time.time()
pushResult()
end
end, function (checkedName)