Skip to content

Commit 2ee33da

Browse files
committed
fix diagnostics
1 parent 37d33ca commit 2ee33da

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

script/files.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ function m.setText(uri, text, isTrust, version)
219219
file.cache = {}
220220
file.cacheActiveTime = math.huge
221221
m.globalVersion = m.globalVersion + 1
222-
await.close('files.version')
223222
m.onWatch('version')
224223
if create then
225224
m.onWatch('create', uri)
@@ -411,7 +410,6 @@ function m.remove(uri)
411410
m.fileCount = m.fileCount - 1
412411
m.globalVersion = m.globalVersion + 1
413412

414-
await.close('files.version')
415413
m.onWatch('version')
416414
m.onWatch('remove', originUri)
417415
end

script/progress.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function mt:remove()
4343
})
4444
--log.info('Remove progress:', token, self._title)
4545
end
46+
47+
log.info('Remove progress:', self._title, self._token)
4648
end
4749

4850
---设置描述
@@ -158,6 +160,8 @@ function m.create(scp, title, delay)
158160

159161
m.map[prog._token] = prog
160162

163+
log.info('Create progress:', title, prog._token)
164+
161165
return prog
162166
end
163167

script/provider/diagnostic.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ function m.refresh(uri)
288288
xpcall(m.doDiagnostic, log.error, uri)
289289
end
290290
m.diagnosticsScope(uri)
291-
end, 'files.version')
291+
end)
292292
end
293293

294294
---@async
@@ -351,9 +351,14 @@ function m.diagnosticsScope(uri, force)
351351
if not force and delay < 0 then
352352
return
353353
end
354-
await.close ('diagnosticsScope:' .. (uri or '<fallback>'))
354+
local scp = ws.getScope(uri)
355+
local id = 'diagnosticsScope:' .. scp:getName()
356+
await.close(id)
355357
await.call(function () ---@async
356358
await.sleep(math.max(delay, 0.1))
359+
while loading.count() > 0 do
360+
await.sleep(1.0)
361+
end
357362
local clock = os.clock()
358363
local bar <close> = progress.create(ws.getScope(uri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
359364
local cancelled
@@ -365,9 +370,8 @@ function m.diagnosticsScope(uri, force)
365370
askForDisable(uri)
366371
end)
367372
end)
368-
local scp = ws.getScope(uri)
369373
local uris = files.getAllUris(scp)
370-
log.info(('diagnostics scope [%s], files count:[%d]'):format(scp, #uris))
374+
log.info(('diagnostics scope [%s], files count:[%d]'):format(scp:getName(), #uris))
371375
for i, uri in ipairs(uris) do
372376
while loading.count() > 0 do
373377
await.sleep(1.0)
@@ -383,7 +387,7 @@ function m.diagnosticsScope(uri, force)
383387
end
384388
bar:remove()
385389
log.debug('全文诊断耗时:', os.clock() - clock)
386-
end, 'files.version', ('diagnosticsScope:' .. (uri or '<fallback>')))
390+
end, id)
387391
end
388392

389393
ws.watch(function (ev, uri)
@@ -397,9 +401,7 @@ files.watch(function (ev, uri) ---@async
397401
m.clear(uri)
398402
m.refresh(uri)
399403
elseif ev == 'update' then
400-
if ws.isReady(uri) then
401-
m.refresh(uri)
402-
end
404+
m.refresh(uri)
403405
elseif ev == 'open' then
404406
if ws.isReady(uri) then
405407
xpcall(m.doDiagnostic, log.error, uri)

script/workspace/scope.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ function mt:get(k)
6969
return self._data[k]
7070
end
7171

72+
---@return string
73+
function mt:getName()
74+
return self.uri or ('<' .. self.type .. '>')
75+
end
76+
7277
---@param scopeType scope.type
7378
---@return scope
7479
local function createScope(scopeType)

0 commit comments

Comments
 (0)