Preserve suffix text when applying function suggestion

Updates all PromQL function-like suggestions to omit parentheses
when inserted. Such insertions also preserve any suffix text.

Related: #13885
This commit is contained in:
Michael Huynh
2018-11-09 20:43:20 +08:00
parent 16bf269c31
commit 22b8b04dbe
3 changed files with 62 additions and 61 deletions

View File

@@ -20,8 +20,8 @@ const HISTORY_COUNT_CUTOFF = 1000 * 60 * 60 * 24; // 24h
const wrapLabel = (label: string) => ({ label });
const setFunctionMove = (suggestion: CompletionItem): CompletionItem => {
suggestion.move = -1;
const setFunctionKind = (suggestion: CompletionItem): CompletionItem => {
suggestion.kind = 'function';
return suggestion;
};
@@ -129,7 +129,7 @@ export default class PromQlLanguageProvider extends LanguageProvider {
suggestions.push({
prefixMatch: true,
label: 'Functions',
items: FUNCTIONS.map(setFunctionMove),
items: FUNCTIONS.map(setFunctionKind),
});
if (metrics) {