Notebooks: Fix Selection/Focus when New Cells Added (#3649)

* Improvemnents to Active Cell

* Fix minor spacing issue

* fix editor focus order

* Fix for add cell above/below

* cleanup logic to have activeCell logic all reside in notebook model
This commit is contained in:
Chris LaFreniere
2019-01-02 15:20:05 -08:00
committed by GitHub
parent 5367101330
commit 2d52bc2a49
3 changed files with 26 additions and 20 deletions

View File

@@ -203,9 +203,9 @@ export class NotebookModel extends Disposable implements INotebookModel {
return this._cells.findIndex((cell) => cell.equals(cellModel));
}
public addCell(cellType: CellType, index?: number): void {
public addCell(cellType: CellType, index?: number): ICellModel {
if (this.inErrorState || !this._cells) {
return;
return null;
}
let cell = this.createCell(cellType);
@@ -215,12 +215,18 @@ export class NotebookModel extends Disposable implements INotebookModel {
this._cells.push(cell);
index = undefined;
}
// Set newly created cell as active cell
this._activeCell.active = false;
this._activeCell = cell;
this._activeCell.active = true;
this._contentChangedEmitter.fire({
changeType: NotebookChangeType.CellsAdded,
cells: [cell],
cellIndex: index
});
return cell;
}
private createCell(cellType: CellType): ICellModel {