ui/codemirror-promql: pass DurationExpr node id to getChild

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
Julien Pivotto 2026-06-29 11:13:13 +02:00
parent 55556cbd06
commit 25eaa9f358
No known key found for this signature in database

View file

@ -304,7 +304,7 @@ export function computeStartCompletePosition(state: EditorState, node: SyntaxNod
(node.type.id === 0 &&
(node.parent?.type.id === OffsetExpr ||
node.parent?.type.id === MatrixSelector ||
(node.parent?.type.id === SubqueryExpr && node.parent.getChild('DurationExpr') !== null)))
(node.parent?.type.id === SubqueryExpr && node.parent.getChild(DurationExpr) !== null)))
) {
start = pos;
}
@ -333,7 +333,7 @@ export function analyzeCompletion(state: EditorState, node: SyntaxNode, pos: num
if (
node.parent?.type.id === OffsetExpr ||
node.parent?.type.id === MatrixSelector ||
(node.parent?.type.id === SubqueryExpr && node.parent.getChild('DurationExpr') !== null)
(node.parent?.type.id === SubqueryExpr && node.parent.getChild(DurationExpr) !== null)
) {
// We are in a duration slot. Two situations land here with an error node:
// 1. `go[]` -> the error node text is empty: nothing typed yet, so offer