fix(ssh_config): Only run analyzer if parser had no errors

This commit is contained in:
Myzel394 2024-09-29 21:18:39 +02:00
parent 631de7c33c
commit f5aa4ae7cc
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
2 changed files with 13 additions and 13 deletions

View File

@ -30,10 +30,10 @@ func TextDocumentDidChange(
return err.ToDiagnostic()
},
)...)
} else {
diagnostics = append(diagnostics, analyzer.Analyze(document)...)
}
diagnostics = append(diagnostics, analyzer.Analyze(document)...)
if len(diagnostics) > 0 {
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics)
}

View File

@ -29,19 +29,19 @@ func TextDocumentDidOpen(
sshconfig.DocumentParserMap[params.TextDocument.URI] = document
}
diagnostics := make([]protocol.Diagnostic, 0)
errors := document.Config.Parse(params.TextDocument.Text)
diagnostics := utils.Map(
errors,
func(err common.LSPError) protocol.Diagnostic {
return err.ToDiagnostic()
},
)
diagnostics = append(
diagnostics,
analyzer.Analyze(document)...,
)
if len(errors) > 0 {
diagnostics = append(diagnostics, utils.Map(
errors,
func(err common.LSPError) protocol.Diagnostic {
return err.ToDiagnostic()
},
)...)
} else {
diagnostics = append(diagnostics, analyzer.Analyze(document)...)
}
if len(diagnostics) > 0 {
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics)