summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-03 12:38:41 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-03 12:38:41 +0800
commit181408ad7cc99eb2dc84fa318ebdb0100137fb1c (patch)
tree17b2e66976e266cc4c4a04d463c5e71edb395625 /script-beta
parent116b62f42dc78b2f6559e7d22b9f59741f15db54 (diff)
downloadlua-language-server-181408ad7cc99eb2dc84fa318ebdb0100137fb1c.zip
支持 workspace.maxPreload
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/workspace/workspace.lua20
1 files changed, 18 insertions, 2 deletions
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)