From b745c50723f8e9becc0224b868992d116ffc1e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 11 Dec 2019 19:03:55 +0800 Subject: =?UTF-8?q?=E8=B7=B3=E8=BF=87=E8=BF=87=E5=A4=A7=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/workspace/workspace.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'script-beta/workspace/workspace.lua') diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua index deee764a..f24f825a 100644 --- a/script-beta/workspace/workspace.lua +++ b/script-beta/workspace/workspace.lua @@ -12,6 +12,7 @@ local m = {} m.type = 'workspace' m.ignoreVersion = -1 m.ignoreMatcher = nil +m.preloadVersion = 0 m.uri = '' m.path = '' @@ -133,7 +134,9 @@ function m.awaitPreload() if read >= max then break end - await.sleep(0.1) + await.sleep(0.1, function () + return m.preloadVersion + end) end log.info('Preload finish.') @@ -193,4 +196,12 @@ function m.getRelativePath(uri) return fs.relative(fs.path(path), fs.path(m.path)):string() end +function m.reload() + m.preloadVersion = m.preloadVersion + 1 + files.removeAll() + await.create(function () + m.awaitPreload() + end) +end + return m -- cgit v1.2.3