Skip to content

Commit 8fb9e9f

Browse files
authored
set an empty selection so that get selection does not return undefined (microsoft#250323)
* set an empty selection so that get selection does not return undefined * just change the selection getter * ensure a value from each setter * use internal type
1 parent 5c6caa7 commit 8fb9e9f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as extHostConverter from './extHostTypeConverters.js';
99
import * as extHostTypes from './extHostTypes.js';
1010
import * as vscode from 'vscode';
1111
import { ExtHostNotebookDocument } from './extHostNotebookDocument.js';
12+
import { NotebookRange } from './extHostTypes.js';
1213

1314
export class ExtHostNotebookEditor {
1415

@@ -48,8 +49,8 @@ export class ExtHostNotebookEditor {
4849
if (!Array.isArray(value) || !value.every(extHostTypes.NotebookRange.isNotebookRange)) {
4950
throw illegalArgument('selections');
5051
}
51-
that._selections = value;
52-
that._trySetSelections(value);
52+
that._selections = value.length === 0 ? [new NotebookRange(0, 0)] : value;
53+
that._trySetSelections(that._selections);
5354
},
5455
get visibleRanges() {
5556
return that._visibleRanges;
@@ -93,7 +94,7 @@ export class ExtHostNotebookEditor {
9394
}
9495

9596
_acceptSelections(selections: vscode.NotebookRange[]): void {
96-
this._selections = selections;
97+
this._selections = selections.length === 0 ? [new NotebookRange(0, 0)] : selections;
9798
}
9899

99100
private _trySetSelections(value: vscode.NotebookRange[]): void {

0 commit comments

Comments
 (0)