fix(ssh_config): Fix formatter when match and host are not fully filled

This commit is contained in:
Myzel394 2024-10-01 17:55:35 +02:00
parent 2ea2c1eea8
commit 3d389eb53f
No known key found for this signature in database
GPG Key ID: ED20A1D1D423AF3F

View File

@ -59,6 +59,10 @@ func formatHostBlock(
hostBlock *ast.SSHHostBlock, hostBlock *ast.SSHHostBlock,
options protocol.FormattingOptions, options protocol.FormattingOptions,
) []protocol.TextEdit { ) []protocol.TextEdit {
if hostBlock.HostValue == nil || hostBlock.HostValue.Hosts == nil {
return nil
}
edits := make([]protocol.TextEdit, 0) edits := make([]protocol.TextEdit, 0)
key := fields.FieldsNameFormattedMap[hostBlock.GetEntryOption().Key.Key] key := fields.FieldsNameFormattedMap[hostBlock.GetEntryOption().Key.Key]
@ -78,6 +82,10 @@ func formatMatchBlock(
matchBlock *ast.SSHMatchBlock, matchBlock *ast.SSHMatchBlock,
options protocol.FormattingOptions, options protocol.FormattingOptions,
) []protocol.TextEdit { ) []protocol.TextEdit {
if matchBlock.MatchValue == nil || matchBlock.MatchValue.Entries == nil {
return nil
}
edits := make([]protocol.TextEdit, 0) edits := make([]protocol.TextEdit, 0)
key := fields.FieldsNameFormattedMap[matchBlock.GetEntryOption().Key.Key] key := fields.FieldsNameFormattedMap[matchBlock.GetEntryOption().Key.Key]