mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 04:53:33 +01:00
notebookeditor.selections
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user