Enable status bar for notebooks (#14817)

* enable status bar for notebooks

* add onCellExecutionStart event to notebook service

* fix test, change var name
This commit is contained in:
Lucy Zhang
2021-03-22 14:54:13 -07:00
committed by GitHub
parent 8fb54710fb
commit 780ca84f9a
5 changed files with 33 additions and 3 deletions

View File

@@ -531,6 +531,7 @@ export class CellModel extends Disposable implements ICellModel {
}, false);
this.setFuture(future as FutureInternal);
this.fireExecutionStateChanged();
this._notebookService?.notifyCellExecutionStarted();
// For now, await future completion. Later we should just track and handle cancellation based on model notifications
let result: nb.IExecuteReplyMsg = <nb.IExecuteReplyMsg><any>await future.done;
if (result && result.content) {
@@ -551,6 +552,7 @@ export class CellModel extends Disposable implements ICellModel {
let commandExecuted = this._commandService?.executeCommand(result.commandId, result.args);
// This will ensure that the run button turns into a stop button
this.fireExecutionStateChanged();
this._notebookService?.notifyCellExecutionStarted();
await commandExecuted;
// For save files, if we output a message after saving the file, the file becomes dirty again.
// Special casing this to avoid this particular issue.

View File

@@ -129,6 +129,16 @@ export interface INotebookService {
* @param isTrusted True if notebook is to be set to trusted, false otherwise.
*/
setTrusted(notebookUri: URI, isTrusted: boolean): Promise<boolean>;
/**
* Event that gets fired when a cell is executed.
*/
onCodeCellExecutionStart: Event<void>;
/**
* Fires the onCodeCellExecutionStart event.
*/
notifyCellExecutionStarted(): void;
}
export interface INotebookProvider {

View File

@@ -108,6 +108,7 @@ export class NotebookService extends Disposable implements INotebookService {
private _isRegistrationComplete = false;
private _trustedCacheQueue: URI[] = [];
private _unTrustedCacheQueue: URI[] = [];
private _onCodeCellExecutionStart: Emitter<void> = new Emitter<void>();
constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@@ -639,4 +640,12 @@ export class NotebookService extends Disposable implements INotebookService {
return isTrusted;
}
get onCodeCellExecutionStart(): Event<void> {
return this._onCodeCellExecutionStart.event;
}
notifyCellExecutionStarted(): void {
this._onCodeCellExecutionStart.fire();
}
}