mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 16:57:14 -06:00
don't remove last ] if token type is string
This commit is contained in:
parent
10012f8ffe
commit
bce5b2d56e
@ -5,7 +5,6 @@ export class PromCompleter {
|
||||
labelQueryCache: any;
|
||||
labelNameCache: any;
|
||||
labelValueCache: any;
|
||||
templateVariableCompletions: any;
|
||||
|
||||
identifierRegexps = [/\[/, /[a-zA-Z0-9_:]/];
|
||||
|
||||
@ -13,34 +12,34 @@ export class PromCompleter {
|
||||
this.labelQueryCache = {};
|
||||
this.labelNameCache = {};
|
||||
this.labelValueCache = {};
|
||||
this.templateVariableCompletions = _.flatten(
|
||||
this.templateSrv.variables.map(variable => {
|
||||
return [
|
||||
{
|
||||
caption: '$' + variable.name,
|
||||
value: '$' + variable.name,
|
||||
meta: 'variable.other',
|
||||
score: Number.MAX_VALUE,
|
||||
},
|
||||
{
|
||||
caption: '[[' + variable.name + ']',
|
||||
value: '[[' + variable.name + ']',
|
||||
meta: 'variable.other',
|
||||
score: Number.MAX_VALUE,
|
||||
},
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getCompletions(editor, session, pos, prefix, callback) {
|
||||
let token = session.getTokenAt(pos.row, pos.column);
|
||||
let wrappedCallback = (err, completions) => {
|
||||
completions = completions.concat(this.templateVariableCompletions);
|
||||
let templateVariableCompletions = _.flatten(
|
||||
this.templateSrv.variables.map(variable => {
|
||||
let suffix = token.type.indexOf('string') === 0 ? ']]' : ']';
|
||||
return [
|
||||
{
|
||||
caption: '$' + variable.name,
|
||||
value: '$' + variable.name,
|
||||
meta: 'variable.other',
|
||||
score: Number.MAX_VALUE,
|
||||
},
|
||||
{
|
||||
caption: '[[' + variable.name + suffix,
|
||||
value: '[[' + variable.name + suffix,
|
||||
meta: 'variable.other',
|
||||
score: Number.MAX_VALUE,
|
||||
},
|
||||
];
|
||||
})
|
||||
);
|
||||
completions = completions.concat(templateVariableCompletions);
|
||||
return callback(err, completions);
|
||||
};
|
||||
|
||||
let token = session.getTokenAt(pos.row, pos.column);
|
||||
|
||||
switch (token.type) {
|
||||
case 'entity.name.tag.label-matcher':
|
||||
this.getCompletionsForLabelMatcherName(session, pos).then(completions => {
|
||||
|
Loading…
Reference in New Issue
Block a user