notebookeditor.selections

This commit is contained in:
rebornix
2021-02-19 17:03:33 -08:00
parent 5d2c9bf299
commit e8966ecaa9
13 changed files with 81 additions and 29 deletions

View File

@@ -88,6 +88,7 @@ export class ExtHostNotebookEditor {
//TODO@rebornix noop setter?
selection?: vscode.NotebookCell;
private _selections: vscode.NotebookCellRange[] = [];
private _visibleRanges: extHostTypes.NotebookCellRange[] = [];
private _viewColumn?: vscode.ViewColumn;
@@ -125,6 +126,9 @@ export class ExtHostNotebookEditor {
get selection() {
return that.selection;
},
get selections() {
return that._selections;
},
get visibleRanges() {
return that._visibleRanges;
},
@@ -173,6 +177,24 @@ 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]));
}
}
get active(): boolean {
return this._active;
}