mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 05:07:35 +00:00
Inline parameters to execution task start and end
This commit is contained in:
@@ -69,7 +69,7 @@ class Kernel {
|
||||
await task.replaceOutput([new vscode.NotebookCellOutput([
|
||||
vscode.NotebookCellOutputItem.text('my output', 'text/plain')
|
||||
])]);
|
||||
task.end({ success: true });
|
||||
task.end(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ suite('Notebook API tests', function () {
|
||||
await task.replaceOutput([new vscode.NotebookCellOutput([
|
||||
vscode.NotebookCellOutputItem.text('my second output', 'text/plain')
|
||||
])]);
|
||||
task.end({ success: true });
|
||||
task.end(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -781,7 +781,7 @@ suite('Notebook API tests', function () {
|
||||
await task.replaceOutput([new vscode.NotebookCellOutput([
|
||||
vscode.NotebookCellOutputItem.text('Canceled', 'text/plain')
|
||||
])]);
|
||||
task.end({});
|
||||
task.end(undefined);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -826,7 +826,7 @@ suite('Notebook API tests', function () {
|
||||
await this._task!.replaceOutput([new vscode.NotebookCellOutput([
|
||||
vscode.NotebookCellOutputItem.text('Interrupted', 'text/plain')
|
||||
])]);
|
||||
this._task!.end({});
|
||||
this._task!.end(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1188,7 +1188,7 @@ suite('Notebook API tests', function () {
|
||||
])]);
|
||||
assert.strictEqual(cell.notebook.cellAt(0).outputs.length, 1);
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.notebook.cellAt(0).outputs[0].items[0].data), 'Some output');
|
||||
task.end({});
|
||||
task.end(undefined);
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
||||
48
src/vs/vscode.d.ts
vendored
48
src/vs/vscode.d.ts
vendored
@@ -11933,32 +11933,6 @@ declare module 'vscode' {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
// todo@api jsdoc
|
||||
// todo@api Inline unless we can come up with more (future) properties
|
||||
export interface NotebookCellExecuteStartContext {
|
||||
/**
|
||||
* The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
|
||||
* that shows for how long a cell has been running. If not given, the clock won't be shown.
|
||||
*/
|
||||
startTime?: number;
|
||||
}
|
||||
|
||||
// todo@api jsdoc
|
||||
// todo@api Inline unless we can come up with more (future) properties
|
||||
export interface NotebookCellExecuteEndContext {
|
||||
/**
|
||||
* If true, a green check is shown on the cell status bar.
|
||||
* If false, a red X is shown.
|
||||
* If undefined, no check or X icon is shown.
|
||||
*/
|
||||
success?: boolean;
|
||||
|
||||
/**
|
||||
* The time that execution finished, in milliseconds in the Unix epoch.
|
||||
*/
|
||||
endTime?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A NotebookCellExecution is how {@link NotebookController notebook controller} modify a notebook cell as
|
||||
* it is executing.
|
||||
@@ -11988,13 +11962,23 @@ declare module 'vscode' {
|
||||
*/
|
||||
executionOrder: number | undefined;
|
||||
|
||||
// todo@API inline context object?
|
||||
// @rob inline as arguments
|
||||
start(context?: NotebookCellExecuteStartContext): void;
|
||||
/**
|
||||
* Signal that the execution has begun.
|
||||
*
|
||||
* @param startTime The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
|
||||
* that shows for how long a cell has been running. If not given, the clock won't be shown.
|
||||
*/
|
||||
start(startTime?: number): void;
|
||||
|
||||
// todo@API inline context object?
|
||||
// @rob inline as arguments
|
||||
end(result?: NotebookCellExecuteEndContext): void;
|
||||
/**
|
||||
* Signal that execution has ended.
|
||||
*
|
||||
* @param success If true, a green check is shown on the cell status bar.
|
||||
* If false, a red X is shown.
|
||||
* If undefined, no check or X icon is shown.
|
||||
* @param endTime The time that execution finished, in milliseconds in the Unix epoch.
|
||||
*/
|
||||
end(success: boolean | undefined, endTime?: number): void;
|
||||
|
||||
/**
|
||||
* Clears the output of the cell that is executing or of another cell that is affected by this execution.
|
||||
|
||||
@@ -447,7 +447,7 @@ class NotebookCellExecutionTask extends Disposable {
|
||||
});
|
||||
},
|
||||
|
||||
start(context?: vscode.NotebookCellExecuteStartContext): void {
|
||||
start(startTime?: number): void {
|
||||
if (that._state === NotebookCellExecutionTaskState.Resolved || that._state === NotebookCellExecutionTaskState.Started) {
|
||||
throw new Error('Cannot call start again');
|
||||
}
|
||||
@@ -457,11 +457,11 @@ class NotebookCellExecutionTask extends Disposable {
|
||||
|
||||
that.mixinMetadata({
|
||||
runState: NotebookCellExecutionState.Executing,
|
||||
runStartTime: context?.startTime ?? null
|
||||
runStartTime: startTime ?? null
|
||||
});
|
||||
},
|
||||
|
||||
end(result?: vscode.NotebookCellExecuteEndContext): void {
|
||||
end(success: boolean | undefined, endTime?: number): void {
|
||||
if (that._state === NotebookCellExecutionTaskState.Resolved) {
|
||||
throw new Error('Cannot call resolve twice');
|
||||
}
|
||||
@@ -471,8 +471,8 @@ class NotebookCellExecutionTask extends Disposable {
|
||||
|
||||
that.mixinMetadata({
|
||||
runState: null,
|
||||
lastRunSuccess: result?.success ?? null,
|
||||
runEndTime: result?.endTime ?? null,
|
||||
lastRunSuccess: success ?? null,
|
||||
runEndTime: endTime ?? null,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user