Skip to content

Commit 7321df7

Browse files
committed
use time.time instead of os.clock
the implementation of os.clock under the windows platform is inconsistent with other platforms
1 parent cea9695 commit 7321df7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

script/progress.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local proto = require 'proto.proto'
22
local util = require 'utility'
33
local timer = require "timer"
44
local config = require 'config'
5+
local time = require 'bee.time'
56

67
local nextToken = util.counter()
78

@@ -81,8 +82,8 @@ function mt:_update()
8182
return
8283
end
8384
if not self._showed
84-
and self._clock + self._delay <= os.clock() then
85-
self._updated = os.clock()
85+
and self._clock + self._delay <= time.time() then
86+
self._updated = time.time()
8687
self._dirty = false
8788
if not config.get(self._scp.uri, 'Lua.window.progressBar') then
8889
return
@@ -111,11 +112,11 @@ function mt:_update()
111112
self:remove()
112113
return
113114
end
114-
if os.clock() - self._updated < 0.05 then
115+
if time.time() - self._updated < 0.05 then
115116
return
116117
end
117118
self._dirty = false
118-
self._updated = os.clock()
119+
self._updated = time.time()
119120
proto.notify('$/progress', {
120121
token = self._token,
121122
value = {
@@ -151,8 +152,8 @@ function m.create(scp, title, delay)
151152
local prog = setmetatable({
152153
_token = nextToken(),
153154
_title = title,
154-
_clock = os.clock(),
155-
_delay = delay,
155+
_clock = time.time(),
156+
_delay = delay * 1000,
156157
_scp = scp,
157158
}, mt)
158159

script/provider/diagnostic.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local client = require 'client'
1212
local converter = require 'proto.converter'
1313
local loading = require 'workspace.loading'
1414
local scope = require 'workspace.scope'
15+
local time = require 'bee.time'
1516

1617
---@class diagnosticProvider
1718
local m = {}
@@ -260,13 +261,13 @@ function m.doDiagnostic(uri, isScopeDiag)
260261

261262
pushResult()
262263

263-
local lastPushClock = os.clock()
264+
local lastPushClock = time.time()
264265
---@async
265266
xpcall(core, log.error, uri, isScopeDiag, function (result)
266267
diags[#diags+1] = buildDiagnostic(uri, result)
267268

268-
if not isScopeDiag and os.clock() - lastPushClock >= 0.2 then
269-
lastPushClock = os.clock()
269+
if not isScopeDiag and time.time() - lastPushClock >= 200 then
270+
lastPushClock = time.time()
270271
pushResult()
271272
end
272273
end, function (checkedName)

0 commit comments

Comments
 (0)