From ae07ea940e77cc23eba78e717a09d99233841620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 10 Apr 2022 03:49:54 +0800 Subject: cancel searching reference --- script/vm/ref.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'script/vm/ref.lua') 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 = 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 -- cgit v1.2.3