diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-27 17:43:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-27 17:43:49 +0800 |
commit | 716d7dfde6e13d3192745a75fbc814f644e593e8 (patch) | |
tree | ccf556db298a469f33e49ec7bc4fc47c12a7be4e /script/service/telemetry.lua | |
parent | aa669fd32b51f338dfc76e8efd40ade98431537b (diff) | |
download | lua-language-server-716d7dfde6e13d3192745a75fbc814f644e593e8.zip |
fix telemetry window blocks initializing
Diffstat (limited to 'script/service/telemetry.lua')
-rw-r--r-- | script/service/telemetry.lua | 85 |
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 |