From 38bf2879644243f5d8423c33a2dad2a43e2eb230 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 29 May 2025 15:55:00 +0200 Subject: [PATCH 1/3] Increase timeout for opening new notebook editors in testing --- packages/vscode-common/src/testUtil/openNewEditor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-common/src/testUtil/openNewEditor.ts b/packages/vscode-common/src/testUtil/openNewEditor.ts index 7024312027..3c0642e9ca 100644 --- a/packages/vscode-common/src/testUtil/openNewEditor.ts +++ b/packages/vscode-common/src/testUtil/openNewEditor.ts @@ -110,7 +110,7 @@ function waitForEditorToOpen() { if (vscode.window.activeTextEditor != null) { clearInterval(interval); // Give it a moment to settle - setTimeout(resolve, 100); + setTimeout(resolve, 200); } else { count++; if (count === 20) { From 663a180e1c042595b1ffb8d83e34e1620f5c9320 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 29 May 2025 15:57:13 +0200 Subject: [PATCH 2/3] Clean up --- packages/vscode-common/src/testUtil/openNewEditor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vscode-common/src/testUtil/openNewEditor.ts b/packages/vscode-common/src/testUtil/openNewEditor.ts index 3c0642e9ca..153fd2af12 100644 --- a/packages/vscode-common/src/testUtil/openNewEditor.ts +++ b/packages/vscode-common/src/testUtil/openNewEditor.ts @@ -98,19 +98,19 @@ export async function openNewNotebookEditor( // FIXME: There seems to be some timing issue when you create a notebook // editor - await waitForEditorToOpen(); + await waitForEditorToOpen(cellContents.length); return document; } -function waitForEditorToOpen() { +function waitForEditorToOpen(numCells: number): Promise { return new Promise((resolve, reject) => { let count = 0; const interval = setInterval(() => { if (vscode.window.activeTextEditor != null) { clearInterval(interval); // Give it a moment to settle - setTimeout(resolve, 200); + setTimeout(resolve, 100 * numCells); } else { count++; if (count === 20) { From 3091439ecf4acfcee0eb4a9ddd9616c5752e094b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 30 May 2025 07:31:17 +0200 Subject: [PATCH 3/3] update --- .../src/suite/crossCellsSetSelection.vscode.test.ts | 3 +++ packages/vscode-common/src/testUtil/openNewEditor.ts | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts b/packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts index 3d5175bca8..20bafdef6c 100644 --- a/packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts +++ b/packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts @@ -1,3 +1,4 @@ +import { sleep } from "@cursorless/common"; import { getCursorlessApi, openNewNotebookEditor, @@ -19,6 +20,8 @@ async function runTest() { await openNewNotebookEditor(['"hello"', '"world"']); + await sleep(200); + await hatTokenMap.allocateHats(); await runCursorlessCommand({ diff --git a/packages/vscode-common/src/testUtil/openNewEditor.ts b/packages/vscode-common/src/testUtil/openNewEditor.ts index 153fd2af12..ff7e82008b 100644 --- a/packages/vscode-common/src/testUtil/openNewEditor.ts +++ b/packages/vscode-common/src/testUtil/openNewEditor.ts @@ -98,19 +98,18 @@ export async function openNewNotebookEditor( // FIXME: There seems to be some timing issue when you create a notebook // editor - await waitForEditorToOpen(cellContents.length); + await waitForEditorToOpen(); return document; } -function waitForEditorToOpen(numCells: number): Promise { +function waitForEditorToOpen(): Promise { return new Promise((resolve, reject) => { let count = 0; const interval = setInterval(() => { if (vscode.window.activeTextEditor != null) { clearInterval(interval); - // Give it a moment to settle - setTimeout(resolve, 100 * numCells); + resolve(); } else { count++; if (count === 20) {