diff options
-rw-r--r-- | script/files.lua | 2 | ||||
-rw-r--r-- | script/progress.lua | 4 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 18 | ||||
-rw-r--r-- | script/workspace/scope.lua | 5 |
4 files changed, 19 insertions, 10 deletions
diff --git a/script/files.lua b/script/files.lua index 0b6c1e09..4b7f8cf2 100644 --- a/script/files.lua +++ b/script/files.lua @@ -219,7 +219,6 @@ function m.setText(uri, text, isTrust, version) file.cache = {} file.cacheActiveTime = math.huge m.globalVersion = m.globalVersion + 1 - await.close('files.version') m.onWatch('version') if create then m.onWatch('create', uri) @@ -411,7 +410,6 @@ function m.remove(uri) m.fileCount = m.fileCount - 1 m.globalVersion = m.globalVersion + 1 - await.close('files.version') m.onWatch('version') m.onWatch('remove', originUri) end diff --git a/script/progress.lua b/script/progress.lua index d5c174ce..2e31f753 100644 --- a/script/progress.lua +++ b/script/progress.lua @@ -43,6 +43,8 @@ function mt:remove() }) --log.info('Remove progress:', token, self._title) end + + log.info('Remove progress:', self._title, self._token) end ---设置描述 @@ -158,6 +160,8 @@ function m.create(scp, title, delay) m.map[prog._token] = prog + log.info('Create progress:', title, prog._token) + return prog end diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 0a3c4384..94e69838 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -288,7 +288,7 @@ function m.refresh(uri) xpcall(m.doDiagnostic, log.error, uri) end m.diagnosticsScope(uri) - end, 'files.version') + end) end ---@async @@ -351,9 +351,14 @@ function m.diagnosticsScope(uri, force) if not force and delay < 0 then return end - await.close ('diagnosticsScope:' .. (uri or '<fallback>')) + local scp = ws.getScope(uri) + local id = 'diagnosticsScope:' .. scp:getName() + await.close(id) await.call(function () ---@async await.sleep(math.max(delay, 0.1)) + while loading.count() > 0 do + await.sleep(1.0) + end local clock = os.clock() local bar <close> = progress.create(ws.getScope(uri), lang.script.WORKSPACE_DIAGNOSTIC, 1) local cancelled @@ -365,9 +370,8 @@ function m.diagnosticsScope(uri, force) askForDisable(uri) end) end) - local scp = ws.getScope(uri) local uris = files.getAllUris(scp) - log.info(('diagnostics scope [%s], files count:[%d]'):format(scp, #uris)) + log.info(('diagnostics scope [%s], files count:[%d]'):format(scp:getName(), #uris)) for i, uri in ipairs(uris) do while loading.count() > 0 do await.sleep(1.0) @@ -383,7 +387,7 @@ function m.diagnosticsScope(uri, force) end bar:remove() log.debug('全文诊断耗时:', os.clock() - clock) - end, 'files.version', ('diagnosticsScope:' .. (uri or '<fallback>'))) + end, id) end ws.watch(function (ev, uri) @@ -397,9 +401,7 @@ files.watch(function (ev, uri) ---@async m.clear(uri) m.refresh(uri) elseif ev == 'update' then - if ws.isReady(uri) then - m.refresh(uri) - end + m.refresh(uri) elseif ev == 'open' then if ws.isReady(uri) then xpcall(m.doDiagnostic, log.error, uri) diff --git a/script/workspace/scope.lua b/script/workspace/scope.lua index a9e8447e..5c9a1756 100644 --- a/script/workspace/scope.lua +++ b/script/workspace/scope.lua @@ -69,6 +69,11 @@ function mt:get(k) return self._data[k] end +---@return string +function mt:getName() + return self.uri or ('<' .. self.type .. '>') +end + ---@param scopeType scope.type ---@return scope local function createScope(scopeType) |