diff options
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/files.lua | 22 | ||||
-rw-r--r-- | server-beta/src/provider/diagnostic.lua | 12 |
2 files changed, 33 insertions, 1 deletions
diff --git a/server-beta/src/files.lua b/server-beta/src/files.lua index 076c491b..34c8c2de 100644 --- a/server-beta/src/files.lua +++ b/server-beta/src/files.lua @@ -195,6 +195,28 @@ function m.getOriginUri(uri) return file.uri end +function m.setDiagnostic(uri, diag) + if platform.OS == 'Windows' then + uri = uri:lower() + end + local file = m.fileMap[uri] + if not file then + return + end + file._diag = diag +end + +function m.getDiagnostic(uri) + if platform.OS == 'Windows' then + uri = uri:lower() + end + local file = m.fileMap[uri] + if not file then + return nil + end + return file._diag +end + --- 寻找全局变量 function m.findGlobals(name) local uris = {} diff --git a/server-beta/src/provider/diagnostic.lua b/server-beta/src/provider/diagnostic.lua index 6583c8d8..df5fd419 100644 --- a/server-beta/src/provider/diagnostic.lua +++ b/server-beta/src/provider/diagnostic.lua @@ -144,10 +144,20 @@ function m.doDiagnostic(uri, syntaxOnly) local syntax = m.syntaxErrors(uri, ast) local diagnostics = m.diagnostics(uri, syntaxOnly) + local newDiag = merge(syntax, diagnostics) + local lastDiag = files.getDiagnostic(uri) + if #newDiag == 0 then + if not lastDiag then + return + end + files.setDiagnostic(uri, nil) + else + files.setDiagnostic(uri, newDiag) + end proto.notify('textDocument/publishDiagnostics', { uri = uri, - diagnostics = merge(syntax, diagnostics), + diagnostics = newDiag, }) end |