@@ -18,16 +18,19 @@ export class ExtHostNotebookEditor {
18
18
private _visible : boolean = false ;
19
19
20
20
private _editor ?: vscode . NotebookEditor ;
21
+ private _selections : vscode . NotebookRange [ ] = [ new NotebookRange ( 0 , 0 ) ] ;
21
22
22
23
constructor (
23
24
readonly id : string ,
24
25
private readonly _proxy : MainThreadNotebookEditorsShape ,
25
26
readonly notebookData : ExtHostNotebookDocument ,
26
27
private _visibleRanges : vscode . NotebookRange [ ] ,
27
- private _selections : vscode . NotebookRange [ ] ,
28
+ selections : vscode . NotebookRange [ ] ,
28
29
private _viewColumn : vscode . ViewColumn | undefined ,
29
30
private readonly viewType : string
30
- ) { }
31
+ ) {
32
+ this . _selections = this . _validSelections ( selections ) ;
33
+ }
31
34
32
35
get apiEditor ( ) : vscode . NotebookEditor {
33
36
if ( ! this . _editor ) {
@@ -49,7 +52,7 @@ export class ExtHostNotebookEditor {
49
52
if ( ! Array . isArray ( value ) || ! value . every ( extHostTypes . NotebookRange . isNotebookRange ) ) {
50
53
throw illegalArgument ( 'selections' ) ;
51
54
}
52
- that . _selections = value . length === 0 ? [ new NotebookRange ( 0 , 0 ) ] : value ;
55
+ that . _selections = that . _validSelections ( value ) ;
53
56
that . _trySetSelections ( that . _selections ) ;
54
57
} ,
55
58
get visibleRanges ( ) {
@@ -94,7 +97,7 @@ export class ExtHostNotebookEditor {
94
97
}
95
98
96
99
_acceptSelections ( selections : vscode . NotebookRange [ ] ) : void {
97
- this . _selections = selections . length === 0 ? [ new NotebookRange ( 0 , 0 ) ] : selections ;
100
+ this . _selections = this . _validSelections ( selections ) ;
98
101
}
99
102
100
103
private _trySetSelections ( value : vscode . NotebookRange [ ] ) : void {
@@ -104,4 +107,8 @@ export class ExtHostNotebookEditor {
104
107
_acceptViewColumn ( value : vscode . ViewColumn | undefined ) {
105
108
this . _viewColumn = value ;
106
109
}
110
+
111
+ private _validSelections ( selections : vscode . NotebookRange [ ] ) {
112
+ return selections . length === 0 ? [ new NotebookRange ( 0 , 0 ) ] : selections ;
113
+ }
107
114
}
0 commit comments