prometheus: monaco: stricter autocomplete and handle space (#41028)
* prometheus: monaco: stricter autocomplete * autocomplete on space
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ export function getCompletionProvider(
|
||||
};
|
||||
|
||||
return {
|
||||
triggerCharacters: ['{', ',', '[', '(', '=', '~'],
|
||||
triggerCharacters: ['{', ',', '[', '(', '=', '~', ' '],
|
||||
provideCompletionItems,
|
||||
};
|
||||
}
|
||||
|
||||
+2
@@ -46,6 +46,8 @@ describe('intent', () => {
|
||||
assertIntent('something{}[^]', {
|
||||
type: 'ALL_DURATIONS',
|
||||
});
|
||||
|
||||
assertIntent('something{label~^}', null);
|
||||
});
|
||||
|
||||
it('handles label names', () => {
|
||||
|
||||
+13
@@ -389,7 +389,20 @@ function resolveDurations(node: SyntaxNode, text: string, pos: number): Intent {
|
||||
};
|
||||
}
|
||||
|
||||
function subTreeHasError(node: SyntaxNode): boolean {
|
||||
return getNodeInSubtree(node, ERROR_NODE_NAME) !== null;
|
||||
}
|
||||
|
||||
function resolveLabelKeysWithEquals(node: SyntaxNode, text: string, pos: number): Intent | null {
|
||||
// for example `something{^}`
|
||||
|
||||
// there are some false positives that can end up in this situation, that we want
|
||||
// to eliminate, for example: `something{a~^}`
|
||||
// basically, if this subtree contains any error-node, we stop
|
||||
if (subTreeHasError(node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const metricNameNode = walk(node, [
|
||||
['parent', 'VectorSelector'],
|
||||
['firstChild', 'MetricIdentifier'],
|
||||
|
||||
Reference in New Issue
Block a user