mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
fix(server): Overall bugfixes & improvements
This commit is contained in:
parent
5de2711b03
commit
db4e1bae4c
@ -177,7 +177,7 @@ func (v KeyEnumAssignmentValue) DeprecatedFetchCompletions(line string, cursor u
|
||||
)
|
||||
|
||||
if found {
|
||||
relativePosition := min(foundPosition, len(line) - 1)
|
||||
relativePosition := min(foundPosition, len(line)-1)
|
||||
selectedKey := line[:uint32(relativePosition)]
|
||||
line = line[uint32(relativePosition+len(v.Separator)):]
|
||||
cursor -= uint32(relativePosition)
|
||||
|
@ -141,8 +141,8 @@ func (e FstabEntry) FetchMountOptionsField(includeDefaults bool) docvalues.Depre
|
||||
return nil
|
||||
}
|
||||
|
||||
var enums []docvalues.EnumString
|
||||
var assignable map[docvalues.EnumString]docvalues.DeprecatedValue
|
||||
var enums []docvalues.EnumString = make([]docvalues.EnumString, 0)
|
||||
var assignable map[docvalues.EnumString]docvalues.DeprecatedValue = make(map[docvalues.EnumString]docvalues.DeprecatedValue, 0)
|
||||
|
||||
if includeDefaults {
|
||||
enums = append(option.Enums, fields.DefaultOptions...)
|
||||
|
@ -6,6 +6,31 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func createMountOptionField(
|
||||
options []docvalues.EnumString,
|
||||
assignOption map[docvalues.EnumString]docvalues.DeprecatedValue,
|
||||
) docvalues.DeprecatedValue {
|
||||
// dynamicOptions := docvalues.MergeKeyEnumAssignmentMaps(defaultAssignOptions, assignOption)
|
||||
|
||||
return docvalues.ArrayValue{
|
||||
Separator: ",",
|
||||
DuplicatesExtractor: &MountOptionsExtractor,
|
||||
SubValue: docvalues.OrValue{
|
||||
Values: []docvalues.DeprecatedValue{
|
||||
docvalues.KeyEnumAssignmentValue{
|
||||
Values: assignOption,
|
||||
ValueIsOptional: false,
|
||||
Separator: "=",
|
||||
},
|
||||
docvalues.EnumValue{
|
||||
EnforceValues: true,
|
||||
Values: options,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var MountOptionsExtractor = func(value string) string {
|
||||
separatorIndex := strings.Index(value, "=")
|
||||
|
||||
@ -339,31 +364,6 @@ Added in version 233.`,
|
||||
): docvalues.StringValue{},
|
||||
}
|
||||
|
||||
func createMountOptionField(
|
||||
options []docvalues.EnumString,
|
||||
assignOption map[docvalues.EnumString]docvalues.DeprecatedValue,
|
||||
) docvalues.DeprecatedValue {
|
||||
// dynamicOptions := docvalues.MergeKeyEnumAssignmentMaps(defaultAssignOptions, assignOption)
|
||||
|
||||
return docvalues.ArrayValue{
|
||||
Separator: ",",
|
||||
DuplicatesExtractor: &MountOptionsExtractor,
|
||||
SubValue: docvalues.OrValue{
|
||||
Values: []docvalues.DeprecatedValue{
|
||||
docvalues.KeyEnumAssignmentValue{
|
||||
Values: assignOption,
|
||||
ValueIsOptional: false,
|
||||
Separator: "=",
|
||||
},
|
||||
docvalues.EnumValue{
|
||||
EnforceValues: true,
|
||||
Values: options,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type optionField struct {
|
||||
Assignable map[docvalues.EnumString]docvalues.DeprecatedValue
|
||||
Enums []docvalues.EnumString
|
||||
|
@ -46,26 +46,27 @@ func GetCompletion(
|
||||
|
||||
optionsValue := entry.FetchMountOptionsField(false)
|
||||
|
||||
if optionsValue == nil {
|
||||
optionsValue = fields.DefaultMountOptionsField
|
||||
if optionsValue != nil {
|
||||
for _, completion := range optionsValue.DeprecatedFetchCompletions(line, cursor) {
|
||||
var documentation string
|
||||
|
||||
switch completion.Documentation.(type) {
|
||||
case string:
|
||||
documentation = completion.Documentation.(string)
|
||||
case *string:
|
||||
documentation = *completion.Documentation.(*string)
|
||||
}
|
||||
|
||||
completion.Documentation = protocol.MarkupContent{
|
||||
Kind: protocol.MarkupKindMarkdown,
|
||||
Value: documentation + "\n\n" + fmt.Sprintf("From: _%s_", fileSystemType),
|
||||
}
|
||||
completions = append(completions, completion)
|
||||
}
|
||||
}
|
||||
|
||||
for _, completion := range optionsValue.DeprecatedFetchCompletions(line, cursor) {
|
||||
var documentation string
|
||||
|
||||
switch completion.Documentation.(type) {
|
||||
case string:
|
||||
documentation = completion.Documentation.(string)
|
||||
case *string:
|
||||
documentation = *completion.Documentation.(*string)
|
||||
}
|
||||
|
||||
completion.Documentation = protocol.MarkupContent{
|
||||
Kind: protocol.MarkupKindMarkdown,
|
||||
Value: documentation + "\n\n" + fmt.Sprintf("From: _%s_", fileSystemType),
|
||||
}
|
||||
completions = append(completions, completion)
|
||||
}
|
||||
// Add defaults
|
||||
completions = append(completions, fields.DefaultMountOptionsField.DeprecatedFetchCompletions(line, cursor)...)
|
||||
|
||||
return completions, nil
|
||||
case ast.FstabFieldFreq:
|
||||
|
Loading…
x
Reference in New Issue
Block a user