From 3d389eb53fd4cf97cf9316cad7a5b1f27071bb99 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:55:35 +0200 Subject: [PATCH] fix(ssh_config): Fix formatter when match and host are not fully filled --- handlers/ssh_config/handlers/formatting_nodes.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/handlers/ssh_config/handlers/formatting_nodes.go b/handlers/ssh_config/handlers/formatting_nodes.go index 2cbd8f7..9e9a2df 100644 --- a/handlers/ssh_config/handlers/formatting_nodes.go +++ b/handlers/ssh_config/handlers/formatting_nodes.go @@ -59,6 +59,10 @@ func formatHostBlock( hostBlock *ast.SSHHostBlock, options protocol.FormattingOptions, ) []protocol.TextEdit { + if hostBlock.HostValue == nil || hostBlock.HostValue.Hosts == nil { + return nil + } + edits := make([]protocol.TextEdit, 0) key := fields.FieldsNameFormattedMap[hostBlock.GetEntryOption().Key.Key] @@ -78,6 +82,10 @@ func formatMatchBlock( matchBlock *ast.SSHMatchBlock, options protocol.FormattingOptions, ) []protocol.TextEdit { + if matchBlock.MatchValue == nil || matchBlock.MatchValue.Entries == nil { + return nil + } + edits := make([]protocol.TextEdit, 0) key := fields.FieldsNameFormattedMap[matchBlock.GetEntryOption().Key.Key]