mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
fix(sshd_config): Do not show all completions when inside a match block
This commit is contained in:
parent
9cf1403bbd
commit
683be36a03
@ -7,6 +7,7 @@ import (
|
|||||||
"config-lsp/handlers/sshd_config/ast"
|
"config-lsp/handlers/sshd_config/ast"
|
||||||
"config-lsp/handlers/sshd_config/fields"
|
"config-lsp/handlers/sshd_config/fields"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||||
)
|
)
|
||||||
@ -16,6 +17,8 @@ func GetRootCompletions(
|
|||||||
parentMatchBlock *ast.SSHDMatchBlock,
|
parentMatchBlock *ast.SSHDMatchBlock,
|
||||||
suggestValue bool,
|
suggestValue bool,
|
||||||
) ([]protocol.CompletionItem, error) {
|
) ([]protocol.CompletionItem, error) {
|
||||||
|
println("getting root completions and the parnet Match block eta:")
|
||||||
|
println(fmt.Sprintf("%v", parentMatchBlock))
|
||||||
kind := protocol.CompletionItemKindField
|
kind := protocol.CompletionItemKindField
|
||||||
|
|
||||||
availableOptions := make(map[string]docvalues.DocumentationValue, 0)
|
availableOptions := make(map[string]docvalues.DocumentationValue, 0)
|
||||||
@ -23,24 +26,22 @@ func GetRootCompletions(
|
|||||||
for key, option := range fields.Options {
|
for key, option := range fields.Options {
|
||||||
var exists = false
|
var exists = false
|
||||||
|
|
||||||
|
// Don't allow duplicates
|
||||||
if optionsMap, found := d.Indexes.AllOptionsPerName[key]; found {
|
if optionsMap, found := d.Indexes.AllOptionsPerName[key]; found {
|
||||||
if _, found := optionsMap[parentMatchBlock]; found {
|
if _, found := optionsMap[parentMatchBlock]; found {
|
||||||
exists = true
|
exists = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists || utils.KeyExists(fields.AllowedDuplicateOptions, key) {
|
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 {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(availableOptions, option.Key.Key)
|
if parentMatchBlock != nil && !utils.KeyExists(fields.MatchAllowedOptions, key) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
availableOptions[key] = option
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.MapMapToSlice(
|
return utils.MapMapToSlice(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user