diff options
-rw-r--r-- | .vscode/settings.json | 3 | ||||
-rw-r--r-- | package.json | 6 | ||||
-rw-r--r-- | server/src/config.lua | 1 | ||||
-rw-r--r-- | server/src/service.lua | 5 |
4 files changed, 12 insertions, 3 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index a18e43b3..6941e67b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ "Lua.diagnostics.disable": [ ], "Lua.runtime.version": "Lua 5.4", - "Lua.workspace.maxPreload": 400 + "Lua.workspace.maxPreload": 400, + "Lua.workspace.preloadFileSize": 1000 } diff --git a/package.json b/package.json index dacc1930..ca3376ae 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,12 @@ "type": "integer", "default": 300, "description": "Max preloaded files.\n最大预加载文件数。" + }, + "Lua.workspace.preloadFileSize": { + "scope": "resource", + "type": "integer", + "default": 100, + "description": "Skip files larger than this value (KB) when preloading.\n预加载时跳过大小大于该值(KB)的文件。" } } } diff --git a/server/src/config.lua b/server/src/config.lua index 79a7d98d..c155eab2 100644 --- a/server/src/config.lua +++ b/server/src/config.lua @@ -52,6 +52,7 @@ local Template = { ignoreSubmodules= {true, Boolean}, useGitIgnore = {true, Boolean}, maxPreload = {300, Integer}, + preloadFileSize = {100, Integer}, } } diff --git a/server/src/service.lua b/server/src/service.lua index f14b0a9b..d35256bf 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -219,8 +219,9 @@ function mt:readText(uri, path, buf, compiled) log.debug('No file: ', path) return end - if #text > 100000 then - log.info(('Skip large file, size: %.3f KB: %s'):format(#text / 1000.0, uri)) + local size = #text / 1000.0 + if size > config.config.workspace.preloadFileSize then + log.info(('Skip large file, size: %.3f KB: %s'):format(size, uri)) return end if self:getCachedFileCount() >= config.config.workspace.maxPreload then |