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]