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() return err.ToDiagnostic()
}, },
)...) )...)
} else {
diagnostics = append(diagnostics, analyzer.Analyze(document)...)
} }
diagnostics = append(diagnostics, analyzer.Analyze(document)...)
if len(diagnostics) > 0 { if len(diagnostics) > 0 {
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics) common.SendDiagnostics(context, params.TextDocument.URI, diagnostics)
} }

View File

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