mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +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 {
|
if found {
|
||||||
relativePosition := min(foundPosition, len(line) - 1)
|
relativePosition := min(foundPosition, len(line)-1)
|
||||||
selectedKey := line[:uint32(relativePosition)]
|
selectedKey := line[:uint32(relativePosition)]
|
||||||
line = line[uint32(relativePosition+len(v.Separator)):]
|
line = line[uint32(relativePosition+len(v.Separator)):]
|
||||||
cursor -= uint32(relativePosition)
|
cursor -= uint32(relativePosition)
|
||||||
|
@ -141,8 +141,8 @@ func (e FstabEntry) FetchMountOptionsField(includeDefaults bool) docvalues.Depre
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var enums []docvalues.EnumString
|
var enums []docvalues.EnumString = make([]docvalues.EnumString, 0)
|
||||||
var assignable map[docvalues.EnumString]docvalues.DeprecatedValue
|
var assignable map[docvalues.EnumString]docvalues.DeprecatedValue = make(map[docvalues.EnumString]docvalues.DeprecatedValue, 0)
|
||||||
|
|
||||||
if includeDefaults {
|
if includeDefaults {
|
||||||
enums = append(option.Enums, fields.DefaultOptions...)
|
enums = append(option.Enums, fields.DefaultOptions...)
|
||||||
|
@ -6,6 +6,31 @@ import (
|
|||||||
"strings"
|
"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 {
|
var MountOptionsExtractor = func(value string) string {
|
||||||
separatorIndex := strings.Index(value, "=")
|
separatorIndex := strings.Index(value, "=")
|
||||||
|
|
||||||
@ -339,31 +364,6 @@ Added in version 233.`,
|
|||||||
): docvalues.StringValue{},
|
): 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 {
|
type optionField struct {
|
||||||
Assignable map[docvalues.EnumString]docvalues.DeprecatedValue
|
Assignable map[docvalues.EnumString]docvalues.DeprecatedValue
|
||||||
Enums []docvalues.EnumString
|
Enums []docvalues.EnumString
|
||||||
|
@ -46,10 +46,7 @@ func GetCompletion(
|
|||||||
|
|
||||||
optionsValue := entry.FetchMountOptionsField(false)
|
optionsValue := entry.FetchMountOptionsField(false)
|
||||||
|
|
||||||
if optionsValue == nil {
|
if optionsValue != nil {
|
||||||
optionsValue = fields.DefaultMountOptionsField
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, completion := range optionsValue.DeprecatedFetchCompletions(line, cursor) {
|
for _, completion := range optionsValue.DeprecatedFetchCompletions(line, cursor) {
|
||||||
var documentation string
|
var documentation string
|
||||||
|
|
||||||
@ -66,6 +63,10 @@ func GetCompletion(
|
|||||||
}
|
}
|
||||||
completions = append(completions, completion)
|
completions = append(completions, completion)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add defaults
|
||||||
|
completions = append(completions, fields.DefaultMountOptionsField.DeprecatedFetchCompletions(line, cursor)...)
|
||||||
|
|
||||||
return completions, nil
|
return completions, nil
|
||||||
case ast.FstabFieldFreq:
|
case ast.FstabFieldFreq:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user