feat(ssh_config): Use formatted option key for formatting

This commit is contained in:
Myzel394 2024-10-01 14:52:07 +02:00
parent cdb463c4d7
commit ed57871b4f
No known key found for this signature in database
GPG Key ID: ED20A1D1D423AF3F

View File

@ -3,6 +3,7 @@ package handlers
import ( import (
"config-lsp/common/formatting" "config-lsp/common/formatting"
"config-lsp/handlers/ssh_config/ast" "config-lsp/handlers/ssh_config/ast"
"config-lsp/handlers/ssh_config/fields"
hostparser "config-lsp/handlers/ssh_config/host-parser" hostparser "config-lsp/handlers/ssh_config/host-parser"
matchparser "config-lsp/handlers/ssh_config/match-parser" matchparser "config-lsp/handlers/ssh_config/match-parser"
"config-lsp/utils" "config-lsp/utils"
@ -30,7 +31,7 @@ func formatSSHOption(
var key string var key string
if option.Key != nil { if option.Key != nil {
key = string(option.Key.Key) key = fields.FieldsNameFormattedMap[option.Key.Key]
} else { } else {
key = "" key = ""
} }
@ -58,11 +59,12 @@ func formatSSHMatchBlock(
) []protocol.TextEdit { ) []protocol.TextEdit {
edits := make([]protocol.TextEdit, 0) edits := make([]protocol.TextEdit, 0)
key := fields.FieldsNameFormattedMap[matchBlock.GetEntryOption().Key.Key]
edits = append(edits, protocol.TextEdit{ edits = append(edits, protocol.TextEdit{
Range: matchBlock.GetEntryOption().ToLSPRange(), Range: matchBlock.GetEntryOption().ToLSPRange(),
NewText: matchTemplate.Format( NewText: matchTemplate.Format(
options, options,
matchBlock.GetEntryOption().Key.Key, key,
formatMatchToString(matchBlock.MatchValue), formatMatchToString(matchBlock.MatchValue),
), ),
}) })
@ -117,11 +119,12 @@ func formatSSHHostBlock(
) []protocol.TextEdit { ) []protocol.TextEdit {
edits := make([]protocol.TextEdit, 0) edits := make([]protocol.TextEdit, 0)
key := fields.FieldsNameFormattedMap[hostBlock.GetEntryOption().Key.Key]
edits = append(edits, protocol.TextEdit{ edits = append(edits, protocol.TextEdit{
Range: hostBlock.GetEntryOption().ToLSPRange(), Range: hostBlock.GetEntryOption().ToLSPRange(),
NewText: matchTemplate.Format( NewText: matchTemplate.Format(
options, options,
hostBlock.GetEntryOption().Key.Key, key,
formatHostToString(hostBlock.HostValue), formatHostToString(hostBlock.HostValue),
), ),
}) })