From 6e5727e12576b19801611168f7e6dfeb81775401 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 4 Apr 2023 16:19:05 -0700 Subject: [PATCH 1/2] Update jsdoc for onWillSaveNotebookDocument (#179179) --- .../extHostNotebookDocumentSaveParticipant.ts | 2 +- ...ode.proposed.notebookDocumentWillSave.d.ts | 48 +++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts b/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts index e9547b63069..1e6a706a305 100644 --- a/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts @@ -53,7 +53,7 @@ export class ExtHostNotebookDocumentSaveParticipant implements ExtHostNotebookDo const edits: WorkspaceEdit[] = []; - await this._onWillSaveNotebookDocumentEvent.fireAsync({ document: document.apiNotebook, reason: TextDocumentSaveReason.to(reason) }, token, async (thenable: Promise, listener) => { + await this._onWillSaveNotebookDocumentEvent.fireAsync({ notebook: document.apiNotebook, reason: TextDocumentSaveReason.to(reason) }, token, async (thenable: Promise, listener) => { const now = Date.now(); const data = await await Promise.resolve(thenable); if (Date.now() - now > this._thresholds.timeout) { diff --git a/src/vscode-dts/vscode.proposed.notebookDocumentWillSave.d.ts b/src/vscode-dts/vscode.proposed.notebookDocumentWillSave.d.ts index e751bbcf669..03281761e1d 100644 --- a/src/vscode-dts/vscode.proposed.notebookDocumentWillSave.d.ts +++ b/src/vscode-dts/vscode.proposed.notebookDocumentWillSave.d.ts @@ -5,11 +5,11 @@ declare module 'vscode' { /** - * An event that is fired when a {@link NotebookDocument document} will be saved. + * An event that is fired when a {@link NotebookDocument notebook document} will be saved. * * To make modifications to the document before it is being saved, call the * {@linkcode NotebookDocumentWillSaveEvent.waitUntil waitUntil}-function with a thenable - * that resolves to an array of {@link TextEdit text edits}. + * that resolves to a {@link WorkspaceEdit workspace edit}. */ export interface NotebookDocumentWillSaveEvent { /** @@ -18,22 +18,62 @@ declare module 'vscode' { readonly token: CancellationToken; /** - * The document that will be saved. + * The {@link NotebookDocument notebook document} that will be saved. */ - readonly document: NotebookDocument; + readonly notebook: NotebookDocument; /** * The reason why save was triggered. */ readonly reason: TextDocumentSaveReason; + /** + * Allows to pause the event loop and to apply {@link WorkspaceEdit workspace edit}. + * Edits of subsequent calls to this function will be applied in order. The + * edits will be *ignored* if concurrent modifications of the notebook document happened. + * + * *Note:* This function can only be called during event dispatch and not + * in an asynchronous manner: + * + * ```ts + * workspace.onWillSaveNotebookDocument(event => { + * // async, will *throw* an error + * setTimeout(() => event.waitUntil(promise)); + * + * // sync, OK + * event.waitUntil(promise); + * }) + * ``` + * + * @param thenable A thenable that resolves to {@link WorkspaceEdit workspace edit}. + */ waitUntil(thenable: Thenable): void; + /** + * Allows to pause the event loop until the provided thenable resolved. + * + * *Note:* This function can only be called during event dispatch. + * + * @param thenable A thenable that delays saving. + */ waitUntil(thenable: Thenable): void; } export namespace workspace { + /** + * An event that is emitted when a {@link NotebookDocument notebook document} will be saved to disk. + * + * *Note 1:* Subscribers can delay saving by registering asynchronous work. For the sake of data integrity the editor + * might save without firing this event. For instance when shutting down with dirty files. + * + * *Note 2:* Subscribers are called sequentially and they can {@link NotebookDocumentWillSaveEvent.waitUntil delay} saving + * by registering asynchronous work. Protection against misbehaving listeners is implemented as such: + * * there is an overall time budget that all listeners share and if that is exhausted no further listener is called + * * listeners that take a long time or produce errors frequently will not be called anymore + * + * The current thresholds are 1.5 seconds as overall time budget and a listener can misbehave 3 times before being ignored. + */ export const onWillSaveNotebookDocument: Event; } } From 6b0d9d79e1178e341b8f27dba4cc0f7b8cd45883 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Tue, 4 Apr 2023 16:53:46 -0700 Subject: [PATCH 2/2] build: properly install built-in extensions for tests (#179216) Uses a cache and GH token to avoid hitting rate limits. Fixes #179181 --- build/azure-pipelines/linux/product-build-linux-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/azure-pipelines/linux/product-build-linux-test.yml b/build/azure-pipelines/linux/product-build-linux-test.yml index a5a30a340fc..b5fa333311f 100644 --- a/build/azure-pipelines/linux/product-build-linux-test.yml +++ b/build/azure-pipelines/linux/product-build-linux-test.yml @@ -38,6 +38,8 @@ steps: stat $ELECTRON_ROOT/chrome-sandbox displayName: Change setuid helper binary permission + - template: ../common/install-builtin-extensions.yml + - ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - script: ./scripts/test.sh --tfs "Unit Tests"