summaryrefslogtreecommitdiff
path: root/script/service/telemetry.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-27 17:43:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-27 17:43:49 +0800
commit716d7dfde6e13d3192745a75fbc814f644e593e8 (patch)
treeccf556db298a469f33e49ec7bc4fc47c12a7be4e /script/service/telemetry.lua
parentaa669fd32b51f338dfc76e8efd40ade98431537b (diff)
downloadlua-language-server-716d7dfde6e13d3192745a75fbc814f644e593e8.zip
fix telemetry window blocks initializing
Diffstat (limited to 'script/service/telemetry.lua')
-rw-r--r--script/service/telemetry.lua85
1 files changed, 44 insertions, 41 deletions
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua
index 7248a9d9..30b26586 100644
--- a/script/service/telemetry.lua
+++ b/script/service/telemetry.lua
@@ -8,6 +8,7 @@ local platform = require 'bee.platform'
local proto = require 'proto.proto'
local lang = require 'language'
local define = require 'proto.define'
+local await = require 'await'
local tokenPath = (ROOT / 'log' / 'token'):string()
local token = util.loadFile(tokenPath)
@@ -100,51 +101,53 @@ function m.updateConfig()
end
m.hasShowedMessage = true
- if client.isVSCode() then
- local enableTitle = lang.script.WINDOW_TELEMETRY_ENABLE
- local disableTitle = lang.script.WINDOW_TELEMETRY_DISABLE
- local item = proto.awaitRequest('window/showMessageRequest', {
- message = lang.script.WINDOW_TELEMETRY_HINT,
- type = define.MessageType.Info,
- actions = {
- {
- title = enableTitle,
- },
- {
- title = disableTitle,
- },
- }
- })
- if not item then
- return
- end
- if item.title == enableTitle then
- proto.notify('$/command', {
- command = 'lua.config',
- data = {
- key = 'Lua.telemetry.enable',
- action = 'set',
- value = true,
- global = true,
+ await.call(function ()
+ if client.isVSCode() then
+ local enableTitle = lang.script.WINDOW_TELEMETRY_ENABLE
+ local disableTitle = lang.script.WINDOW_TELEMETRY_DISABLE
+ local item = proto.awaitRequest('window/showMessageRequest', {
+ message = lang.script.WINDOW_TELEMETRY_HINT,
+ type = define.MessageType.Info,
+ actions = {
+ {
+ title = enableTitle,
+ },
+ {
+ title = disableTitle,
+ },
}
})
- elseif item.title == disableTitle then
- proto.notify('$/command', {
- command = 'lua.config',
- data = {
- key = 'Lua.telemetry.enable',
- action = 'set',
- value = false,
- global = true,
- }
+ if not item then
+ return
+ end
+ if item.title == enableTitle then
+ proto.notify('$/command', {
+ command = 'lua.config',
+ data = {
+ key = 'Lua.telemetry.enable',
+ action = 'set',
+ value = true,
+ global = true,
+ }
+ })
+ elseif item.title == disableTitle then
+ proto.notify('$/command', {
+ command = 'lua.config',
+ data = {
+ key = 'Lua.telemetry.enable',
+ action = 'set',
+ value = false,
+ global = true,
+ }
+ })
+ end
+ else
+ proto.notify('window/showMessage', {
+ message = lang.script.WINDOW_TELEMETRY_HINT,
+ type = define.MessageType.Info,
})
end
- else
- proto.notify('window/showMessage', {
- message = lang.script.WINDOW_TELEMETRY_HINT,
- type = define.MessageType.Info,
- })
- end
+ end)
end
return m