Loki: Autocomplete returning labels already in use when cursor is before or between other labels (#75925)

* Fix issue getting current labels that would only grab values to the left of the cursor

* Loki: Fix Autocomplete in stream selector overwriting existing label names, or inserting autocomplete result within label value (#76485)

* Better autocomplete functionality in loki, changing the word pattern to include label value separator (=), include valid sting chars (-), and value wrapper ("), adding some more logic in the range calculation to prevent autocomplete results from partially overwriting adjacent label names or portions of the current label value
This commit is contained in:
Galen Kistler
2023-10-13 10:26:32 -05:00
committed by GitHub
parent c4b02d7063
commit f2ad66620f
6 changed files with 320 additions and 19 deletions

View File

@@ -259,7 +259,7 @@ export function handleExpression(expr: string, node: SyntaxNode, context: Contex
function getLabel(expr: string, node: SyntaxNode): QueryBuilderLabelFilter {
const labelNode = node.getChild(Identifier);
const label = getString(expr, labelNode);
const op = getString(expr, labelNode!.nextSibling);
const op = getString(expr, labelNode?.nextSibling);
let value = getString(expr, node.getChild(String));
// `value` is wrapped in double quotes, so we need to remove them. As a value can contain double quotes, we can't use RegEx here.
value = value.substring(1, value.length - 1);