Skip to content

Commit c9f19f8

Browse files
authored
cover the constructor as well (microsoft#250675)
1 parent 00e555f commit c9f19f8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/vs/workbench/api/common/extHostNotebookEditor.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ export class ExtHostNotebookEditor {
1818
private _visible: boolean = false;
1919

2020
private _editor?: vscode.NotebookEditor;
21+
private _selections: vscode.NotebookRange[] = [new NotebookRange(0, 0)];
2122

2223
constructor(
2324
readonly id: string,
2425
private readonly _proxy: MainThreadNotebookEditorsShape,
2526
readonly notebookData: ExtHostNotebookDocument,
2627
private _visibleRanges: vscode.NotebookRange[],
27-
private _selections: vscode.NotebookRange[],
28+
selections: vscode.NotebookRange[],
2829
private _viewColumn: vscode.ViewColumn | undefined,
2930
private readonly viewType: string
30-
) { }
31+
) {
32+
this._selections = this._validSelections(selections);
33+
}
3134

3235
get apiEditor(): vscode.NotebookEditor {
3336
if (!this._editor) {
@@ -49,7 +52,7 @@ export class ExtHostNotebookEditor {
4952
if (!Array.isArray(value) || !value.every(extHostTypes.NotebookRange.isNotebookRange)) {
5053
throw illegalArgument('selections');
5154
}
52-
that._selections = value.length === 0 ? [new NotebookRange(0, 0)] : value;
55+
that._selections = that._validSelections(value);
5356
that._trySetSelections(that._selections);
5457
},
5558
get visibleRanges() {
@@ -94,7 +97,7 @@ export class ExtHostNotebookEditor {
9497
}
9598

9699
_acceptSelections(selections: vscode.NotebookRange[]): void {
97-
this._selections = selections.length === 0 ? [new NotebookRange(0, 0)] : selections;
100+
this._selections = this._validSelections(selections);
98101
}
99102

100103
private _trySetSelections(value: vscode.NotebookRange[]): void {
@@ -104,4 +107,8 @@ export class ExtHostNotebookEditor {
104107
_acceptViewColumn(value: vscode.ViewColumn | undefined) {
105108
this._viewColumn = value;
106109
}
110+
111+
private _validSelections(selections: vscode.NotebookRange[]) {
112+
return selections.length === 0 ? [new NotebookRange(0, 0)] : selections;
113+
}
107114
}

0 commit comments

Comments
 (0)