fix range of configFile diagnostics
This commit is contained in:
parent
fe05e038d5
commit
3a87cacccc
1 changed files with 12 additions and 7 deletions
|
@ -61,16 +61,21 @@ export default class TypeScriptServiceClientHost implements Disposable {
|
||||||
if (body) {
|
if (body) {
|
||||||
let { configFile, diagnostics } = body
|
let { configFile, diagnostics } = body
|
||||||
let uri = Uri.file(configFile)
|
let uri = Uri.file(configFile)
|
||||||
let language = this.findLanguage(uri)
|
|
||||||
if (!language) return
|
|
||||||
if (diagnostics.length == 0) {
|
if (diagnostics.length == 0) {
|
||||||
this.client.diagnosticsManager.configFileDiagnosticsReceived(uri.toString(), [])
|
this.client.diagnosticsManager.configFileDiagnosticsReceived(uri.toString(), [])
|
||||||
} else {
|
} else {
|
||||||
let range = Range.create(Position.create(0, 0), Position.create(0, 1))
|
let diagnosticList = diagnostics.map(o => {
|
||||||
let { text, code, category } = diagnostics[0]
|
let { text, code, category, start, end } = o
|
||||||
|
let range: Range
|
||||||
|
if (!start || !end) {
|
||||||
|
range = Range.create(Position.create(0, 0), Position.create(0, 1))
|
||||||
|
} else {
|
||||||
|
range = Range.create(start.line - 1, start.offset - 1, end.line - 1, end.offset - 1)
|
||||||
|
}
|
||||||
let severity = category == 'error' ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning
|
let severity = category == 'error' ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning
|
||||||
let diagnostic = Diagnostic.create(range, text, severity, code)
|
return Diagnostic.create(range, text, severity, code)
|
||||||
this.client.diagnosticsManager.configFileDiagnosticsReceived(uri.toString(), [diagnostic])
|
})
|
||||||
|
this.client.diagnosticsManager.configFileDiagnosticsReceived(uri.toString(), diagnosticList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null, this.disposables)
|
}, null, this.disposables)
|
||||||
|
|
Loading…
Reference in a new issue