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
|
textFormat := protocol.InsertTextFormatPlainText
|
||||||
kind := protocol.CompletionItemKindText
|
kind := protocol.CompletionItemKindText
|
||||||
|
|
||||||
prefixCompletions := utils.Map(v.Prefixes, func(prefix Prefix) protocol.CompletionItem {
|
// Check if the line starts with a prefix
|
||||||
return protocol.CompletionItem{
|
startsWithPrefix := false
|
||||||
Label: prefix.Prefix,
|
for _, prefix := range v.Prefixes {
|
||||||
Detail: &prefix.Meaning,
|
if strings.HasPrefix(line, prefix.Prefix) {
|
||||||
InsertTextFormat: &textFormat,
|
startsWithPrefix = true
|
||||||
Kind: &kind,
|
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)...)
|
return append(prefixCompletions, v.SubValue.FetchCompletions(line, cursor)...)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user