From 181408ad7cc99eb2dc84fa318ebdb0100137fb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 3 Nov 2020 12:38:41 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=20workspace.maxPreload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/workspace/workspace.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'script-beta/workspace') diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua index e75e280f..1ea48b0c 100644 --- a/script-beta/workspace/workspace.lua +++ b/script-beta/workspace/workspace.lua @@ -7,6 +7,8 @@ local glob = require 'glob' local platform = require 'bee.platform' local await = require 'await' local rpath = require 'workspace.require-path' +local proto = require 'proto.proto' +local lang = require 'language' local m = {} m.type = 'workspace' @@ -142,6 +144,19 @@ local function loadFileFactory(root, progress, isLibrary) if not files.isLua(uri) then return end + if progress.preload >= config.config.workspace.maxPreload then + if not m.hasHitMaxPreload then + m.hasHitMaxPreload = true + proto.notify('window/showMessage', { + type = 3, + message = lang.script('MWS_MAX_PRELOAD', config.config.workspace.maxPreload), + }) + end + return + end + if not isLibrary then + progress.preload = progress.preload + 1 + end progress.max = progress.max + 1 pub.task('loadFile', uri, function (text) progress.read = progress.read + 1 @@ -162,8 +177,9 @@ function m.awaitPreload() await.close 'preload' await.setID 'preload' local progress = { - max = 0, - read = 0, + max = 0, + read = 0, + preload = 0, } log.info('Preload start.') local nativeLoader = loadFileFactory(m.path, progress) -- cgit v1.2.3