mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(doc-values): Check if value starts with a prefix before suggesting prefix completions
This commit is contained in:
parent
06182ddda7
commit
590786e844
@ -46,14 +46,26 @@ func (v PrefixWithMeaningValue) FetchCompletions(line string, cursor uint32) []p
|
||||
textFormat := protocol.InsertTextFormatPlainText
|
||||
kind := protocol.CompletionItemKindText
|
||||
|
||||
prefixCompletions := utils.Map(v.Prefixes, func(prefix Prefix) protocol.CompletionItem {
|
||||
return protocol.CompletionItem{
|
||||
Label: prefix.Prefix,
|
||||
Detail: &prefix.Meaning,
|
||||
InsertTextFormat: &textFormat,
|
||||
Kind: &kind,
|
||||
// Check if the line starts with a prefix
|
||||
startsWithPrefix := false
|
||||
for _, prefix := range v.Prefixes {
|
||||
if strings.HasPrefix(line, prefix.Prefix) {
|
||||
startsWithPrefix = true
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var prefixCompletions []protocol.CompletionItem
|
||||
if !startsWithPrefix {
|
||||
prefixCompletions = utils.Map(v.Prefixes, func(prefix Prefix) protocol.CompletionItem {
|
||||
return protocol.CompletionItem{
|
||||
Label: prefix.Prefix,
|
||||
Detail: &prefix.Meaning,
|
||||
InsertTextFormat: &textFormat,
|
||||
Kind: &kind,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return append(prefixCompletions, v.SubValue.FetchCompletions(line, cursor)...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user