Editor focus based on activeCell, create text in edit, scroll to active (#3725)

This commit is contained in:
Chris LaFreniere
2019-01-14 16:39:36 -08:00
committed by GitHub
parent 1fa03b5c74
commit 6dc4096299
4 changed files with 37 additions and 6 deletions

View File

@@ -62,6 +62,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
private _defaultKernel: nb.IKernelSpec;
private _activeCell: ICellModel;
private _providerId: string;
private _isNewNotebook: boolean = true;
constructor(private notebookOptions: INotebookModelOptions, startSessionImmediately?: boolean, private connectionProfile?: IConnectionProfile) {
super();
@@ -170,6 +171,10 @@ export class NotebookModel extends Disposable implements INotebookModel {
return this._trustedMode;
}
public get isNewNotebook(): boolean {
return this._isNewNotebook;
}
public get providerId(): string {
return this._providerId;
}
@@ -218,6 +223,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
version: ''
};
if (contents) {
this._isNewNotebook = false;
this._defaultLanguageInfo = this.getDefaultLanguageInfo(contents);
this._savedKernelInfo = this.getSavedKernelInfo(contents);
if (contents.cells && contents.cells.length > 0) {
@@ -250,7 +256,9 @@ export class NotebookModel extends Disposable implements INotebookModel {
index = undefined;
}
// Set newly created cell as active cell
this._activeCell.active = false;
if (this._activeCell) {
this._activeCell.active = false;
}
this._activeCell = cell;
this._activeCell.active = true;