fix(editor): keep scroll after canceling dangerous sql

This commit is contained in:
jearhe authored and GitHub committed 2026-09-01 12:16:59 +08:00
1 parent a751b5690b
commit 694611aade
9 files changed
+215 -11

No files matched your search

@@ -92,8 +92,11 @@ describe("QueryEditor execution routing", () => {
it("claims gutter viewport ownership only after the matching execution starts", () => {
expect(appSource).toContain("acceptQueryEditorExecutionViewport(editorViewportRequestId)");
expect(appSource).toContain("onExecutionCancelled: (editorViewportRequestId) => contentAreaRef.value?.cancelQueryEditorExecutionViewport(editorViewportRequestId)");
expect(contentAreaSource).toContain("acceptGutterExecutionViewport(requestId)");
expect(contentAreaSource).toContain("cancelGutterExecutionViewport(requestId)");
expect(sqlExecutionSource).toContain("onExecutionStarted: () => deps.onExecutionStarted?.(options.editorViewportRequestId!)");
expect(sqlExecutionSource).toContain("onExecutionCancelled?: (editorViewportRequestId: number) => void;");
expect(queryStoreSource.indexOf("tab.isExecuting = true")).toBeLessThan(queryStoreSource.indexOf("options?.onExecutionStarted?.()"));
});
@@ -160,7 +163,7 @@ describe("QueryEditor execution viewport ownership", () => {
const ownership = createQueryEditorExecutionViewportOwnership();
const cancelledRequestId = ownership.beginRequest();
ownership.cancelPendingRequest();
expect(ownership.cancelPendingRequest(cancelledRequestId)).toBe(true);
expect(ownership.acceptRequest(cancelledRequestId)).toBe(false);
expect(ownership.consumeCompletionPreservation()).toBe(false);
@@ -21,8 +21,11 @@ export function createQueryEditorExecutionViewportOwnership() {
pendingRequestId = nextRequestId;
return nextRequestId;
},
cancelPendingRequest() {
cancelPendingRequest(requestId?: number): boolean {
if (requestId !== undefined && pendingRequestId !== requestId) return false;
if (pendingRequestId === undefined) return false;
pendingRequestId = undefined;
return true;
},
acceptRequest(requestId: number): boolean {
if (pendingRequestId !== requestId) return false;