summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-12 15:56:07 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-12 15:56:07 +0800
commit062bb1ce750a4a7a37b38452b9cf196c491cc6e5 (patch)
treeea5a09e2137447a1a132ebb3524d02ca2fad83a4 /script
parent1b54dfc2def587eb158dd24c7baa2f60ffb95cde (diff)
downloadlua-language-server-062bb1ce750a4a7a37b38452b9cf196c491cc6e5.zip
delay working icon
Diffstat (limited to 'script')
-rw-r--r--script/service/service.lua22
1 files changed, 12 insertions, 10 deletions
diff --git a/script/service/service.lua b/script/service/service.lua
index 14f05ada..44fd9aa4 100644
--- a/script/service/service.lua
+++ b/script/service/service.lua
@@ -141,16 +141,15 @@ end
function m.startTimer()
pub.task('timer', 1)
while true do
- pub.step(not m.working)
+ pub.step(not m.workingClock)
if await.step() then
m.sleeping = false
- if not m.working then
- m.working = true
- m.reportStatus()
+ if not m.workingClock then
+ m.workingClock = time.monotonic()
end
else
- if m.working then
- m.working = false
+ if m.workingClock then
+ m.workingClock = nil
m.idleClock = time.monotonic()
m.reportStatus()
end
@@ -159,9 +158,9 @@ function m.startTimer()
end
end
-function m.checkSleep()
+function m.pulse()
timer.loop(10, function ()
- if not m.working and not m.sleeping and time.monotonic() - m.idleClock >= 300000 then
+ if not m.workingClock and not m.sleeping and time.monotonic() - m.idleClock >= 300000 then
m.sleeping = true
files.flushCache()
vm.flushCache()
@@ -171,11 +170,14 @@ function m.checkSleep()
end
m.reportStatus()
end)
+ timer.loop(0.1, function ()
+ m.reportStatus()
+ end)
end
function m.reportStatus()
local info = {}
- if m.working then
+ if m.workingClock and time.monotonic() - m.workingClock > 100 then
info.text = '$(loading~spin)Lua'
elseif m.sleeping then
info.text = "💤Lua"
@@ -212,7 +214,7 @@ function m.start()
pub.recruitBraves(4)
proto.listen()
m.report()
- m.checkSleep()
+ m.pulse()
m.reportStatus()
m.testVersion()