From f5aa4ae7ccebb76737f640d23fc157791f402080 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sun, 29 Sep 2024 21:18:39 +0200 Subject: [PATCH] fix(ssh_config): Only run analyzer if parser had no errors --- .../lsp/text-document-did-change.go | 4 ++-- .../ssh_config/lsp/text-document-did-open.go | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/handlers/ssh_config/lsp/text-document-did-change.go b/handlers/ssh_config/lsp/text-document-did-change.go index 7650bab..118ace6 100644 --- a/handlers/ssh_config/lsp/text-document-did-change.go +++ b/handlers/ssh_config/lsp/text-document-did-change.go @@ -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) } diff --git a/handlers/ssh_config/lsp/text-document-did-open.go b/handlers/ssh_config/lsp/text-document-did-open.go index 60ef0c1..676738d 100644 --- a/handlers/ssh_config/lsp/text-document-did-open.go +++ b/handlers/ssh_config/lsp/text-document-did-open.go @@ -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)