mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
REPL/IW editor only using a notebook text model (#214356)
* registered editor with notebook model * migrated some stuff from Interactive Editor * display notebook and input box * dont always filter kernels by view * fix restore * implement some commands * working copy recovery/discarding * fix tear down * do not show last cell * simplify notebookOptions creation * reset text model on execute * fix run button * set tab name * use differentiated notebooktype to determine kernel * allow registering notebooks as other priorities * conditionally register actions * move registerAction back to top level * fix input box message * naming * dont register extra repl commands for now * use jupyter-notebook notebook type * set scratchpad on backup recovery * remove unused method
This commit is contained in:
@@ -99,6 +99,7 @@ let MODEL_ID = 0;
|
||||
|
||||
export interface NotebookViewModelOptions {
|
||||
isReadOnly: boolean;
|
||||
inRepl?: boolean;
|
||||
}
|
||||
|
||||
export class NotebookViewModel extends Disposable implements EditorFoldingStateDelegate, INotebookViewModel {
|
||||
@@ -108,15 +109,12 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
private readonly _onDidChangeOptions = this._register(new Emitter<void>());
|
||||
get onDidChangeOptions(): Event<void> { return this._onDidChangeOptions.event; }
|
||||
private _viewCells: CellViewModel[] = [];
|
||||
private readonly replView: boolean;
|
||||
|
||||
get viewCells(): ICellViewModel[] {
|
||||
return this._viewCells;
|
||||
}
|
||||
|
||||
set viewCells(_: ICellViewModel[]) {
|
||||
throw new Error('NotebookViewModel.viewCells is readonly');
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this._viewCells.length;
|
||||
}
|
||||
@@ -206,6 +204,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
MODEL_ID++;
|
||||
this.id = '$notebookViewModel' + MODEL_ID;
|
||||
this._instanceId = strings.singleLetterHash(MODEL_ID);
|
||||
this.replView = !!this.options.inRepl;
|
||||
|
||||
const compute = (changes: NotebookCellTextModelSplice<ICell>[], synchronous: boolean) => {
|
||||
const diffs = changes.map(splice => {
|
||||
@@ -337,9 +336,12 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
this._onDidChangeSelection.fire(e);
|
||||
}));
|
||||
|
||||
this._viewCells = this._notebook.cells.map(cell => {
|
||||
return createCellViewModel(this._instantiationService, this, cell, this._viewContext);
|
||||
});
|
||||
|
||||
const viewCellCount = this.replView ? this._notebook.cells.length - 1 : this._notebook.cells.length;
|
||||
for (let i = 0; i < viewCellCount; i++) {
|
||||
this._viewCells.push(createCellViewModel(this._instantiationService, this, this._notebook.cells[i], this._viewContext));
|
||||
}
|
||||
|
||||
|
||||
this._viewCells.forEach(cell => {
|
||||
this._handleToViewCellMapping.set(cell.handle, cell);
|
||||
|
||||
Reference in New Issue
Block a user