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:
Aaron Munger
2024-09-15 17:16:30 -07:00
committed by GitHub
parent 3be54cca5b
commit e34ecab75b
11 changed files with 56 additions and 36 deletions

View File

@@ -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));
}