mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
easier to use show options, notebook repl editor helper (#228577)
* pass repl flag to exthost notebook, more API helpers * fix parsing label * pass through viewtype instead of isRepl flag
This commit is contained in:
@@ -99,7 +99,6 @@ let MODEL_ID = 0;
|
||||
|
||||
export interface NotebookViewModelOptions {
|
||||
isReadOnly: boolean;
|
||||
inRepl?: boolean;
|
||||
}
|
||||
|
||||
export class NotebookViewModel extends Disposable implements EditorFoldingStateDelegate, INotebookViewModel {
|
||||
@@ -109,7 +108,6 @@ 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;
|
||||
@@ -131,6 +129,10 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
return this._notebook.metadata;
|
||||
}
|
||||
|
||||
private get isRepl() {
|
||||
return this.viewType === 'repl';
|
||||
}
|
||||
|
||||
private readonly _onDidChangeViewCells = this._register(new Emitter<INotebookViewCellsUpdateEvent>());
|
||||
get onDidChangeViewCells(): Event<INotebookViewCellsUpdateEvent> { return this._onDidChangeViewCells.event; }
|
||||
|
||||
@@ -204,7 +206,6 @@ 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,7 +338,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
}));
|
||||
|
||||
|
||||
const viewCellCount = this.replView ? this._notebook.cells.length - 1 : this._notebook.cells.length;
|
||||
const viewCellCount = this.isRepl ? 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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user