Notebooks: Run all after/before (#6239)

* Run all above/below

* PR comments pre tests

* Added integration test
This commit is contained in:
Chris LaFreniere
2019-07-02 16:49:12 -07:00
committed by GitHub
parent 495c9330f6
commit c4bf1b4180
9 changed files with 134 additions and 31 deletions

View File

@@ -155,8 +155,10 @@ export class ExtHostNotebookEditor implements azdata.nb.NotebookEditor, IDisposa
return this._proxy.$runCell(this._id, uri);
}
public runAllCells(): Thenable<boolean> {
return this._proxy.$runAllCells(this._id);
public runAllCells(startCell?: azdata.nb.NotebookCell, endCell?: azdata.nb.NotebookCell): Thenable<boolean> {
let startCellUri = startCell ? startCell.uri : undefined;
let endCellUri = endCell ? endCell.uri : undefined;
return this._proxy.$runAllCells(this._id, startCellUri, endCellUri);
}
public clearOutput(cell: azdata.nb.NotebookCell): Thenable<boolean> {

View File

@@ -132,11 +132,11 @@ class MainThreadNotebookEditor extends Disposable {
return this.editor.runCell(cell);
}
public runAllCells(): Promise<boolean> {
public runAllCells(startCell?: ICellModel, endCell?: ICellModel): Promise<boolean> {
if (!this.editor) {
return Promise.resolve(false);
}
return this.editor.runAllCells();
return this.editor.runAllCells(startCell, endCell);
}
public clearOutput(cell: ICellModel): Promise<boolean> {
@@ -383,12 +383,22 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
return editor.runCell(cell);
}
$runAllCells(id: string): Promise<boolean> {
$runAllCells(id: string, startCellUri?: UriComponents, endCellUri?: UriComponents): Promise<boolean> {
let editor = this.getEditor(id);
if (!editor) {
return Promise.reject(disposed(`TextEditor(${id})`));
}
return editor.runAllCells();
let startCell: ICellModel;
let endCell: ICellModel;
if (startCellUri) {
let uriString = URI.revive(startCellUri).toString();
startCell = editor.cells.find(c => c.cellUri.toString() === uriString);
}
if (endCellUri) {
let uriString = URI.revive(endCellUri).toString();
endCell = editor.cells.find(c => c.cellUri.toString() === uriString);
}
return editor.runAllCells(startCell, endCell);
}
$clearOutput(id: string, cellUri: UriComponents): Promise<boolean> {

View File

@@ -919,7 +919,7 @@ export interface MainThreadNotebookDocumentsAndEditorsShape extends IDisposable
$tryShowNotebookDocument(resource: UriComponents, options: INotebookShowOptions): Promise<string>;
$tryApplyEdits(id: string, modelVersionId: number, edits: ISingleNotebookEditOperation[], opts: IUndoStopOptions): Promise<boolean>;
$runCell(id: string, cellUri: UriComponents): Promise<boolean>;
$runAllCells(id: string): Promise<boolean>;
$runAllCells(id: string, startCellUri?: UriComponents, endCellUri?: UriComponents): Promise<boolean>;
$clearOutput(id: string, cellUri: UriComponents): Promise<boolean>;
$clearAllOutputs(id: string): Promise<boolean>;
$changeKernel(id: string, kernel: azdata.nb.IKernelInfo): Promise<boolean>;