diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-10 03:49:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-10 03:49:54 +0800 |
commit | ae07ea940e77cc23eba78e717a09d99233841620 (patch) | |
tree | 3049b9bcd0ace79f7532df301e228cc9fb6040e9 /script/vm | |
parent | 4e0a890060aea1eb54b14b3a77cba8fc42ceeebb (diff) | |
download | lua-language-server-ae07ea940e77cc23eba78e717a09d99233841620.zip |
cancel searching reference
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/ref.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/script/vm/ref.lua b/script/vm/ref.lua index 472b3b49..59b62c15 100644 --- a/script/vm/ref.lua +++ b/script/vm/ref.lua @@ -8,6 +8,8 @@ local globalMgr = require 'vm.global-manager' local nodeMgr = require 'vm.node' local files = require 'files' local await = require 'await' +local progress = require 'progress' +local lang = require 'language' local simpleSwitch @@ -92,14 +94,24 @@ local function searchInAllFiles(suri, searcher, notify) end end - for _, uri in ipairs(uris) do + local loading <close> = progress.create(suri, lang.script.WINDOW_SEARCHING_IN_FILES, 1) + local cancelled + loading:onCancel(function () + cancelled = true + end) + for i, uri in ipairs(uris) do if notify then local continue = notify(uri) if continue == false then break end end + loading:setMessage(('%03d/%03d'):format(i, #uris)) + loading:setPercentage(i / #uris * 100) await.delay() + if cancelled then + break + end searcher(uri) end end |