From 2e93e214e25933eb528511a5b73ae16fe01822ea Mon Sep 17 00:00:00 2001 From: Pierre Jacquier Date: Thu, 10 Jul 2025 15:31:05 -0400 Subject: [PATCH 1/2] Add catch for empty program in getOperationVariableName Potentially fixes #7686 --- src/lib/operations.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/operations.ts b/src/lib/operations.ts index a1f9c067c1..0b0829d27a 100644 --- a/src/lib/operations.ts +++ b/src/lib/operations.ts @@ -1349,6 +1349,11 @@ export function getOperationVariableName( ) { return undefined } + if (program.body.length === 0) { + // No program body, no variable name + return undefined + } + // Find the AST node. const pathToNode = pathToNodeFromRustNodePath(op.nodePath) if (pathToNode.length === 0) { From b2cfd6b23216eba439c646b5cf66575a81424025 Mon Sep 17 00:00:00 2001 From: Pierre Jacquier Date: Thu, 10 Jul 2025 16:12:04 -0400 Subject: [PATCH 2/2] Another one --- src/lang/queryAst.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/queryAst.ts b/src/lang/queryAst.ts index 70a5553d1e..2c20682e26 100644 --- a/src/lang/queryAst.ts +++ b/src/lang/queryAst.ts @@ -905,6 +905,7 @@ export function isCursorInFunctionDefinition( ast: Node, selectionRanges: Selection ): boolean { + if (ast.body.length === 0) return false if (!selectionRanges?.codeRef?.pathToNode) return false const node = getNodeFromPath( ast,