diff --git a/handlers/sshd_config/handlers/completions.go b/handlers/sshd_config/handlers/completions.go index 3d32060..80cf86c 100644 --- a/handlers/sshd_config/handlers/completions.go +++ b/handlers/sshd_config/handlers/completions.go @@ -7,6 +7,7 @@ import ( "config-lsp/handlers/sshd_config/ast" "config-lsp/handlers/sshd_config/fields" "config-lsp/utils" + "fmt" protocol "github.com/tliron/glsp/protocol_3_16" ) @@ -16,6 +17,8 @@ func GetRootCompletions( parentMatchBlock *ast.SSHDMatchBlock, suggestValue bool, ) ([]protocol.CompletionItem, error) { + println("getting root completions and the parnet Match block eta:") + println(fmt.Sprintf("%v", parentMatchBlock)) kind := protocol.CompletionItemKindField availableOptions := make(map[string]docvalues.DocumentationValue, 0) @@ -23,24 +26,22 @@ func GetRootCompletions( for key, option := range fields.Options { var exists = false + // Don't allow duplicates if optionsMap, found := d.Indexes.AllOptionsPerName[key]; found { if _, found := optionsMap[parentMatchBlock]; found { exists = true } } - if !exists || utils.KeyExists(fields.AllowedDuplicateOptions, key) { - availableOptions[key] = option - } - } - - // Remove all fields that are already present and are not allowed to be duplicated - for _, option := range d.Config.GetAllOptions() { - if _, found := fields.AllowedDuplicateOptions[option.Key.Key]; found { + if exists && !utils.KeyExists(fields.AllowedDuplicateOptions, key) { continue } - delete(availableOptions, option.Key.Key) + if parentMatchBlock != nil && !utils.KeyExists(fields.MatchAllowedOptions, key) { + continue + } + + availableOptions[key] = option } return utils.MapMapToSlice(