From dea95d3e4f6b0d8572e1ff0cb998d30ba67b54cd Mon Sep 17 00:00:00 2001 From: rebornix Date: Sun, 21 Feb 2021 22:24:20 -0800 Subject: [PATCH] map handles to cellrange in UI. --- src/vs/monaco.d.ts | 8 +- .../api/browser/mainThreadNotebook.ts | 7 +- .../workbench/api/common/extHost.protocol.ts | 5 +- .../workbench/api/common/extHostNotebook.ts | 18 +-- .../api/common/extHostNotebookDocument.ts | 4 + .../api/common/extHostNotebookEditor.ts | 21 +-- .../browser/contrib/fold/foldingModel.ts | 11 +- .../notebook/browser/notebookEditorWidget.ts | 14 +- .../notebook/browser/notebookServiceImpl.ts | 2 +- .../viewModel/cellSelectionCollection.ts | 140 ++++++++++++++++++ .../browser/viewModel/notebookViewModel.ts | 73 +++++---- .../contrib/notebook/common/notebookCommon.ts | 4 +- .../notebook/test/testNotebookEditor.ts | 8 +- .../test/browser/api/extHostNotebook.test.ts | 3 +- .../api/extHostNotebookConcatDocument.test.ts | 3 +- 15 files changed, 238 insertions(+), 83 deletions(-) create mode 100644 src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.ts diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 7b729f29901..c8b2e0aec53 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -4088,12 +4088,12 @@ declare namespace monaco.editor { accessibilitySupport: IEditorOption; accessibilityPageSize: IEditorOption; ariaLabel: IEditorOption; - autoClosingBrackets: IEditorOption; - autoClosingOvertype: IEditorOption; - autoClosingQuotes: IEditorOption; + autoClosingBrackets: IEditorOption; + autoClosingOvertype: IEditorOption; + autoClosingQuotes: IEditorOption; autoIndent: IEditorOption; automaticLayout: IEditorOption; - autoSurround: IEditorOption; + autoSurround: IEditorOption; stickyTabStops: IEditorOption; codeLens: IEditorOption; codeLensFontFamily: IEditorOption; diff --git a/src/vs/workbench/api/browser/mainThreadNotebook.ts b/src/vs/workbench/api/browser/mainThreadNotebook.ts index 971303d2247..e04b8e3f9d6 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebook.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebook.ts @@ -98,7 +98,8 @@ class DocumentAndEditorState { return { id: add.getId(), documentUri: add.uri!, - selections: add.getSelectionHandles(), + primary: add.getPrimary(), + selections: add.getSelections(), visibleRanges: add.visibleRanges }; } @@ -247,9 +248,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo })); disposableStore.add(editor.onDidChangeSelection(() => { - const selectionHandles = editor.getSelectionHandles(); - const primarySelection = editor.getPrimarySelection(); - this._proxy.$acceptEditorPropertiesChanged(editor.getId(), { visibleRanges: null, selections: { selections: selectionHandles, primary: primarySelection } }); + this._proxy.$acceptEditorPropertiesChanged(editor.getId(), { visibleRanges: null, selections: { selections: editor.getSelections(), primary: editor.getPrimary() } }); })); this._editorEventListenersMapping.set(editor.getId(), disposableStore); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 827dcf926c1..e64d07c3875 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1744,7 +1744,7 @@ export interface ExtHostCommentsShape { export interface INotebookSelectionChangeEvent { primary: number | null; // handles - selections: number[]; + selections: ICellRange[]; } export interface INotebookVisibleRangesEvent { @@ -1772,7 +1772,8 @@ export interface INotebookModelAddedData { export interface INotebookEditorAddData { id: string; documentUri: UriComponents; - selections: number[]; + primary: number | null; + selections: ICellRange[]; visibleRanges: ICellRange[]; } diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index d528fc04f57..ec2cd81a167 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -17,7 +17,7 @@ import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePa import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; import { asWebviewUri, WebviewInitData } from 'vs/workbench/api/common/shared/webview'; -import { CellStatusbarAlignment, CellUri, INotebookCellStatusBarEntry, INotebookExclusiveDocumentFilter, NotebookCellMetadata, NotebookCellsChangedEventDto, NotebookCellsChangeType, NotebookDataDto, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellStatusbarAlignment, CellUri, ICellRange, INotebookCellStatusBarEntry, INotebookExclusiveDocumentFilter, NotebookCellMetadata, NotebookCellsChangedEventDto, NotebookCellsChangeType, NotebookDataDto, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import * as vscode from 'vscode'; import { ResourceMap } from 'vs/base/common/map'; import { ExtHostCell, ExtHostNotebookDocument } from './extHostNotebookDocument'; @@ -589,9 +589,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { } if (data.selections) { - editor.editor.selection = data.selections.primary !== null ? editor.editor.notebookData.getCell(data.selections.primary)?.cell : undefined; - - editor.editor._acceptSelections(data.selections.selections); + editor.editor._acceptSelections(data.selections.primary, data.selections.selections); this._onDidChangeNotebookEditorSelection.fire({ notebookEditor: editor.editor.editor, @@ -606,7 +604,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { document.acceptDocumentPropertiesChanged(data); } - private _createExtHostEditor(document: ExtHostNotebookDocument, editorId: string, selections: number[], visibleRanges: extHostTypes.NotebookCellRange[]) { + private _createExtHostEditor(document: ExtHostNotebookDocument, editorId: string, primary: number | null, selections: ICellRange[], visibleRanges: extHostTypes.NotebookCellRange[]) { const revivedUri = document.uri; let webComm = this._webviewComm.get(editorId); @@ -622,13 +620,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { document ); - if (selections.length) { - const firstCell = selections[0]; - editor.selection = editor.notebookData.getCell(firstCell)?.cell; - } else { - editor.selection = undefined; - } - + editor._acceptSelections(primary, selections); editor._acceptVisibleRanges(visibleRanges); this._editors.get(editorId)?.editor.dispose(); @@ -734,7 +726,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { const document = this._documents.get(revivedUri); if (document) { - this._createExtHostEditor(document, editorModelData.id, editorModelData.selections, editorModelData.visibleRanges.map(typeConverters.NotebookCellRange.to)); + this._createExtHostEditor(document, editorModelData.id, editorModelData.primary, editorModelData.selections, editorModelData.visibleRanges.map(typeConverters.NotebookCellRange.to)); editorChanged = true; } } diff --git a/src/vs/workbench/api/common/extHostNotebookDocument.ts b/src/vs/workbench/api/common/extHostNotebookDocument.ts index 1e6073def10..b5d865806ef 100644 --- a/src/vs/workbench/api/common/extHostNotebookDocument.ts +++ b/src/vs/workbench/api/common/extHostNotebookDocument.ts @@ -326,6 +326,10 @@ export class ExtHostNotebookDocument extends Disposable { this._emitter.emitCellMetadataChange(event); } + getCellFromIndex(index: number): ExtHostCell | undefined { + return this._cells[index]; + } + getCell(cellHandle: number): ExtHostCell | undefined { return this._cells.find(cell => cell.handle === cellHandle); } diff --git a/src/vs/workbench/api/common/extHostNotebookEditor.ts b/src/vs/workbench/api/common/extHostNotebookEditor.ts index fb9012425e1..b7c17d0f495 100644 --- a/src/vs/workbench/api/common/extHostNotebookEditor.ts +++ b/src/vs/workbench/api/common/extHostNotebookEditor.ts @@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; import * as extHostConverter from 'vs/workbench/api/common/extHostTypeConverters'; -import { CellEditType, ICellEditOperation, ICellReplaceEdit, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellEditType, ICellEditOperation, ICellRange, ICellReplaceEdit, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import * as vscode from 'vscode'; import { ExtHostNotebookDocument } from './extHostNotebookDocument'; @@ -177,22 +177,9 @@ export class ExtHostNotebookEditor { this._visibleRanges = value; } - _acceptSelections(selectionHandles: number[]): void { - const indexes = selectionHandles.map(handle => this.notebookData.getCellIndexFromHandle(handle)).filter(index => index !== undefined).sort() as number[]; - const first = indexes.shift(); - - if (first === undefined) { - this._selections = []; - } else { - this._selections = indexes.reduce(function (ranges, num) { - if (num - ranges[0][1] <= 0) { - ranges[0][1] = num + 1; - } else { - ranges.unshift([num, num + 1]); - } - return ranges; - }, [[first, first + 1]]).reverse().map(val => new extHostTypes.NotebookCellRange(val[0], val[1])); - } + _acceptSelections(primary: number | null, selections: ICellRange[]): void { + this.selection = primary !== null ? this.notebookData.getCellFromIndex(primary)?.cell : undefined; + this._selections = selections.map(val => new extHostTypes.NotebookCellRange(val.start, val.end)); } get active(): boolean { diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel.ts b/src/vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel.ts index 777b97b7de6..5dc6d7fe2bc 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel.ts @@ -52,10 +52,13 @@ export class FoldingModel extends Disposable { return; } - const selectionHandles = this._viewModel.selectionHandles; - const indexes = selectionHandles.map(handle => - this._viewModel!.getCellIndex(this._viewModel!.getCellByHandle(handle)!) - ); + const indexes = this._viewModel.selections.reduce((a, b) => { + for (let i = b.start; i < b.end; i++) { + a.push(i); + } + + return a; + }, [] as number[]); let changed = false; diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index 23dda0f1d90..fc969c961ce 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -335,19 +335,27 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor } getSelectionHandles(): number[] { - return this.viewModel?.selectionHandles || []; + return this.viewModel?.selectionHandles ?? []; } - getPrimarySelection() { + getPrimaryHandle() { return this.viewModel?.primarySelectionHandle ?? null; } + getSelections() { + return this.viewModel?.selections ?? []; + } + + getPrimary() { + return this.viewModel?.primary ?? null; + } + getSelectionViewModels(): ICellViewModel[] { if (!this.viewModel) { return []; } - return this.viewModel.selectionHandles.map(handle => this.viewModel!.getCellByHandle(handle)) as ICellViewModel[]; + return this.viewModel.selections.map(range => this.viewModel!.viewCells.slice(range.start, range.end)).reduce((a, b) => { a.push(...b); return a; }, [] as ICellViewModel[]); } hasModel(): this is IActiveNotebookEditor { diff --git a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts index 5ed21842670..e812634eed0 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts @@ -599,7 +599,7 @@ export class NotebookService extends Disposable implements INotebookService, ICu const selectionIndexes = selectedCells.map(cell => [cell, viewModel.getCellIndex(cell)] as [ICellViewModel, number]).sort((a, b) => b[1] - a[1]); const edits: ICellEditOperation[] = selectionIndexes.map(value => ({ editType: CellEditType.Replace, index: value[1], count: 1, cells: [] })); - viewModel.notebookDocument.applyEdits(viewModel.notebookDocument.versionId, edits, true, { primary: editor.getPrimarySelection(), selections: editor.getSelectionHandles() }, () => { + viewModel.notebookDocument.applyEdits(viewModel.notebookDocument.versionId, edits, true, { primary: editor.getPrimaryHandle(), selections: editor.getSelectionHandles() }, () => { const firstSelectIndex = selectionIndexes[0][1]; if (firstSelectIndex < viewModel.notebookDocument.cells.length) { return { diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.ts new file mode 100644 index 00000000000..bcc35af5e9a --- /dev/null +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.ts @@ -0,0 +1,140 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Emitter, Event } from 'vs/base/common/event'; +import { Disposable } from 'vs/base/common/lifecycle'; +import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookCommon'; + +function selectionsEqual(a: number[], b: number[]) { + if (a.length !== b.length) { + return false; + } + + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; +} + +function rangesEqual(a: ICellRange[], b: ICellRange[]) { + if (a.length !== b.length) { + return false; + } + + for (let i = 0; i < a.length; i++) { + if (a[i].start !== b[i].start || a[i].end !== b[i].end) { + return false; + } + } + + return true; +} + +// Handle first, then we migrate to ICellRange competely +// Challenge is List View talks about `element`, which needs extra work to convert to ICellRange as we support Folding and Cell Move +export class NotebookCellSelectionCollection extends Disposable { + private readonly _onDidChangeSelection = this._register(new Emitter()); + get onDidChangeSelection(): Event { return this._onDidChangeSelection.event; } + + private _primarySelectionHandle: number | null = null; + + get primaryHandle() { + return this._primarySelectionHandle; + } + + set primaryHandle(primary: number | null) { + throw new Error('use setSelections'); + } + private _selectionHandles: number[] = []; + + get allSelectionHandles() { + return this._selectionHandles; + } + + set allSelectionHandles(selections: number[]) { + throw new Error('use setSelections'); + } + + constructor() { + super(); + } + + private _setState(primary: number | null, selections: number[]) { + if (primary === null) { + const changed = primary !== this._primarySelectionHandle || !selectionsEqual(selections, this._selectionHandles); + + this._primarySelectionHandle = primary; + this._selectionHandles = selections; + if (changed) { + this._onDidChangeSelection.fire(); + } + } else { + const newSelections = [primary, ...selections.filter(selection => selection !== primary)]; + const changed = primary !== this._primarySelectionHandle || !selectionsEqual(newSelections, this._selectionHandles); + + this._primarySelectionHandle = primary; + this._selectionHandles = selections; + if (changed) { + this._onDidChangeSelection.fire(); + } + } + } + + setSelections(handles: number[]) { + this._setState(this._primarySelectionHandle, handles); + } + + setFocus(handle: number | null) { + this._setState(handle, this._selectionHandles); + } + + private _primary: number | null = null; + + get primary() { + return this._primary; + } + + private _selections: ICellRange[] = []; + + get selections() { + return this._selections; + } + + private _setState2(primary: number | null, selections: ICellRange[], forceEventEmit: boolean) { + if (primary !== null) { + const primaryRange = { start: primary, end: primary + 1 }; + // TODO@rebornix deal with overlap + const newSelections = [primaryRange, ...selections.filter(selection => selection.start === primaryRange.start && selection.end === primaryRange.end).sort((a, b) => a.start - b.start)]; + + const changed = primary !== this._primary || !rangesEqual(this._selections, newSelections); + this._primary = primary; + this._selections = newSelections; + + if (changed || forceEventEmit) { + this._onDidChangeSelection.fire(); + } + } else { + const changed = primary !== this._primary || !rangesEqual(this._selections, selections); + + this._primary = primary; + this._selections = selections; + + if (changed || forceEventEmit) { + this._onDidChangeSelection.fire(); + } + } + } + + setFocus2(index: number | null, forceEventEmit: boolean) { + this._setState2(index, this._selections, forceEventEmit); + } + + setSelections2(selections: ICellRange[], forceEventEmit: boolean) { + this._setState2(this._primary, selections, forceEventEmit); + } +} diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts index 58c49383392..82f13948784 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts @@ -31,6 +31,7 @@ import { dirname } from 'vs/base/common/resources'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { MultiModelEditStackElement, SingleModelEditStackElement } from 'vs/editor/common/model/editStack'; import { ResourceNotebookCellEdit } from 'vs/workbench/contrib/bulkEdit/browser/bulkCellEdits'; +import { NotebookCellSelectionCollection } from 'vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection'; export interface INotebookEditorViewState { editingCells: { [key: number]: boolean }; @@ -130,20 +131,6 @@ function _normalizeOptions(options: IModelDecorationOptions): ModelDecorationOpt return ModelDecorationOptions.createDynamic(options); } -function selectionsEqual(a: number[], b: number[]) { - if (a.length !== b.length) { - return false; - } - - for (let i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { - return false; - } - } - - return true; -} - let MODEL_ID = 0; @@ -199,34 +186,54 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD private readonly _onDidChangeSelection = this._register(new Emitter()); get onDidChangeSelection(): Event { return this._onDidChangeSelection.event; } - private _primarySelectionHandle: number | null = null; + private _selectionCollection = new NotebookCellSelectionCollection(); + + get selectionCollection() { + return this._selectionCollection; + } get primarySelectionHandle() { - return this._primarySelectionHandle; + return this._selectionCollection.primaryHandle; } set primarySelectionHandle(primary: number | null) { - if (primary === this._primarySelectionHandle) { - return; - } + this._selectionCollection.setFocus(primary); - this._primarySelectionHandle = primary; - this._onDidChangeSelection.fire(); + const index = primary !== null ? this.viewCells.findIndex(cell => cell.handle === primary) : null; + this._selectionCollection.setFocus2(index, true); } - private _selections: number[] = []; get selectionHandles() { - return this._selections; + return this._selectionCollection.allSelectionHandles; } - set selectionHandles(selections: number[]) { - selections = selections.sort(); - if (selectionsEqual(selections, this.selectionHandles)) { - return; - } + set selectionHandles(selectionHandles: number[]) { + this._selectionCollection.setSelections(selectionHandles); - this._selections = selections; - this._onDidChangeSelection.fire(); + const indexes = selectionHandles.map(handle => this._viewCells.findIndex(cell => cell.handle === handle)); + const first = indexes.shift(); + + if (first === undefined) { + this._selectionCollection.setSelections2([], true); + } else { + const selections = indexes.reduce(function (ranges, num) { + if (num - ranges[0][1] <= 0) { + ranges[0][1] = num + 1; + } else { + ranges.unshift([num, num + 1]); + } + return ranges; + }, [[first, first + 1]]).reverse().map(val => ({ start: val[0], end: val[1] })); + this._selectionCollection.setSelections2(selections, true); + } + } + + get primary() { + return this._selectionCollection.primary; + } + + get selections() { + return this._selectionCollection.selections; } private _decorationsTree = new DecorationsTree(); @@ -363,6 +370,10 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD }); })); + this._register(this._selectionCollection.onDidChangeSelection(e => { + this._onDidChangeSelection.fire(e); + })); + this._viewCells = this._notebook.cells.map(cell => { return createCellViewModel(this._instantiationService, this, cell); }); @@ -738,7 +749,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD length, newIdx } - ], synchronous, { primary: this._primarySelectionHandle, selections: this._selections }, () => ({ primary: viewCell.handle, selections: [viewCell.handle] }), undefined); + ], synchronous, { primary: this.primarySelectionHandle, selections: this.selectionHandles }, () => ({ primary: viewCell.handle, selections: [viewCell.handle] }), undefined); return true; } diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index ba4dfae22e0..64cba11ebe7 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -664,7 +664,9 @@ export interface IEditor extends editorCommon.ICompositeCodeEditor { readonly onDidChangeVisibleRanges: Event; readonly onDidChangeSelection: Event; getSelectionHandles(): number[]; - getPrimarySelection(): number | null; + getPrimaryHandle(): number | null; + getPrimary(): number | null; + getSelections(): ICellRange[]; isNotebookEditor: boolean; visibleRanges: ICellRange[]; uri?: URI; diff --git a/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts b/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts index 58165563bda..6fd9e41ddfc 100644 --- a/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts @@ -65,6 +65,12 @@ export class TestNotebookEditor implements INotebookEditor { constructor( ) { } + getPrimary(): number | null { + throw new Error('Method not implemented.'); + } + getSelections(): ICellRange[] { + throw new Error('Method not implemented.'); + } getSelectionViewModels(): ICellViewModel[] { throw new Error('Method not implemented.'); } @@ -115,7 +121,7 @@ export class TestNotebookEditor implements INotebookEditor { return []; } - getPrimarySelection() { + getPrimaryHandle() { return null; } diff --git a/src/vs/workbench/test/browser/api/extHostNotebook.test.ts b/src/vs/workbench/test/browser/api/extHostNotebook.test.ts index a85f77ba805..55cafa0de9b 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebook.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebook.test.ts @@ -85,7 +85,8 @@ suite('NotebookCell#Document', function () { addedEditors: [{ documentUri: notebookUri, id: '_notebook_editor_0', - selections: [0], + primary: 0, + selections: [{ start: 0, end: 1 }], visibleRanges: [] }] }); diff --git a/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts b/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts index 5cd6fcf79cf..6b7ce52b03e 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts @@ -75,7 +75,8 @@ suite('NotebookConcatDocument', function () { { documentUri: notebookUri, id: '_notebook_editor_0', - selections: [0], + primary: 0, + selections: [{ start: 0, end: 1 }], visibleRanges: [] } ]