@@ -40,6 +40,10 @@ export class GotoLineAction extends QuickOpenAction {
4040 run ( ) : Promise < void > {
4141
4242 let activeTextEditorWidget = this . editorService . activeTextEditorWidget ;
43+ if ( ! activeTextEditorWidget ) {
44+ return Promise . resolve ( ) ;
45+ }
46+
4347 if ( isDiffEditor ( activeTextEditorWidget ) ) {
4448 activeTextEditorWidget = activeTextEditorWidget . getModifiedEditor ( ) ;
4549 }
@@ -61,7 +65,7 @@ export class GotoLineAction extends QuickOpenAction {
6165
6266 if ( restoreOptions ) {
6367 Event . once ( this . _quickOpenService . onHide ) ( ( ) => {
64- activeTextEditorWidget . updateOptions ( restoreOptions ! ) ;
68+ activeTextEditorWidget ! . updateOptions ( restoreOptions ! ) ;
6569 } ) ;
6670 }
6771
@@ -92,7 +96,7 @@ class GotoLineEntry extends EditorQuickOpenEntry {
9296 // Inform user about valid range if input is invalid
9397 const maxLineNumber = this . getMaxLineNumber ( ) ;
9498
95- if ( this . invalidRange ( maxLineNumber ) ) {
99+ if ( this . editorService . activeTextEditorWidget && this . invalidRange ( maxLineNumber ) ) {
96100 const position = this . editorService . activeTextEditorWidget . getPosition ( ) ;
97101 if ( position ) {
98102 const currentLine = position . lineNumber ;
@@ -115,6 +119,9 @@ class GotoLineEntry extends EditorQuickOpenEntry {
115119
116120 private getMaxLineNumber ( ) : number {
117121 const activeTextEditorWidget = this . editorService . activeTextEditorWidget ;
122+ if ( ! activeTextEditorWidget ) {
123+ return - 1 ;
124+ }
118125
119126 let model = activeTextEditorWidget . getModel ( ) ;
120127 if ( model && ( < IDiffEditorModel > model ) . modified && ( < IDiffEditorModel > model ) . original ) {
@@ -132,8 +139,8 @@ class GotoLineEntry extends EditorQuickOpenEntry {
132139 return this . runPreview ( ) ;
133140 }
134141
135- getInput ( ) : IEditorInput {
136- return this . editorService . activeEditor ;
142+ getInput ( ) : IEditorInput | null {
143+ return this . editorService . activeEditor || null ;
137144 }
138145
139146 getOptions ( pinned ?: boolean ) : ITextEditorOptions {
@@ -153,7 +160,7 @@ class GotoLineEntry extends EditorQuickOpenEntry {
153160 // Check for sideBySide use
154161 const sideBySide = context . keymods . ctrlCmd ;
155162 if ( sideBySide ) {
156- this . editorService . openEditor ( this . getInput ( ) , this . getOptions ( context . keymods . alt ) , SIDE_GROUP ) ;
163+ this . editorService . openEditor ( this . getInput ( ) ! , this . getOptions ( context . keymods . alt ) , SIDE_GROUP ) ;
157164 }
158165
159166 // Apply selection and focus
@@ -183,8 +190,8 @@ class GotoLineEntry extends EditorQuickOpenEntry {
183190 activeTextEditorWidget . revealRangeInCenter ( range , ScrollType . Smooth ) ;
184191
185192 // Decorate if possible
186- if ( types . isFunction ( activeTextEditorWidget . changeDecorations ) ) {
187- this . handler . decorateOutline ( range , activeTextEditorWidget , this . editorService . activeControl . group ! ) ;
193+ if ( this . editorService . activeControl && types . isFunction ( activeTextEditorWidget . changeDecorations ) ) {
194+ this . handler . decorateOutline ( range , activeTextEditorWidget , this . editorService . activeControl . group ) ;
188195 }
189196 }
190197
@@ -236,7 +243,9 @@ export class GotoLineHandler extends QuickOpenHandler {
236243 // Remember view state to be able to restore on cancel
237244 if ( ! this . lastKnownEditorViewState ) {
238245 const activeTextEditorWidget = this . editorService . activeTextEditorWidget ;
239- this . lastKnownEditorViewState = activeTextEditorWidget . saveViewState ( ) ;
246+ if ( activeTextEditorWidget ) {
247+ this . lastKnownEditorViewState = activeTextEditorWidget . saveViewState ( ) ;
248+ }
240249 }
241250
242251 return Promise . resolve ( new QuickOpenModel ( [ new GotoLineEntry ( searchValue , this . editorService , this ) ] ) ) ;
0 commit comments