@@ -26,15 +26,19 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
2626import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents' ;
2727
2828export class OutputPanel extends AbstractTextResourceEditor {
29+
2930 private actions : IAction [ ] | undefined ;
31+
32+ // Override the instantiation service to use to be the scoped one
3033 private scopedInstantiationService : IInstantiationService ;
31- private _focus = false ;
34+ protected get instantiationService ( ) : IInstantiationService { return this . scopedInstantiationService ; }
35+ protected set instantiationService ( instantiationService : IInstantiationService ) { }
3236
3337 constructor (
3438 @ITelemetryService telemetryService : ITelemetryService ,
3539 @IInstantiationService instantiationService : IInstantiationService ,
3640 @IStorageService storageService : IStorageService ,
37- @IConfigurationService private readonly baseConfigurationService : IConfigurationService ,
41+ @IConfigurationService private readonly configurationService : IConfigurationService ,
3842 @ITextResourceConfigurationService textResourceConfigurationService : ITextResourceConfigurationService ,
3943 @IThemeService themeService : IThemeService ,
4044 @IOutputService private readonly outputService : IOutputService ,
@@ -44,14 +48,11 @@ export class OutputPanel extends AbstractTextResourceEditor {
4448 ) {
4549 super ( OUTPUT_PANEL_ID , telemetryService , instantiationService , storageService , textResourceConfigurationService , themeService , editorGroupService , editorService ) ;
4650
51+ // Initially, the scoped instantiation service is the global
52+ // one until the editor is created later on
4753 this . scopedInstantiationService = instantiationService ;
4854 }
4955
50- protected get instantiationService ( ) : IInstantiationService {
51- // Override instantiation service with our scoped service
52- return this . scopedInstantiationService ;
53- }
54-
5556 getId ( ) : string {
5657 return OUTPUT_PANEL_ID ;
5758 }
@@ -63,10 +64,10 @@ export class OutputPanel extends AbstractTextResourceEditor {
6364 getActions ( ) : IAction [ ] {
6465 if ( ! this . actions ) {
6566 this . actions = [
66- this . instantiationService . createInstance ( SwitchOutputAction ) ,
67- this . instantiationService . createInstance ( ClearOutputAction , ClearOutputAction . ID , ClearOutputAction . LABEL ) ,
68- this . instantiationService . createInstance ( ToggleOrSetOutputScrollLockAction , ToggleOrSetOutputScrollLockAction . ID , ToggleOrSetOutputScrollLockAction . LABEL ) ,
69- this . instantiationService . createInstance ( OpenLogOutputFile )
67+ this . scopedInstantiationService . createInstance ( SwitchOutputAction ) ,
68+ this . scopedInstantiationService . createInstance ( ClearOutputAction , ClearOutputAction . ID , ClearOutputAction . LABEL ) ,
69+ this . scopedInstantiationService . createInstance ( ToggleOrSetOutputScrollLockAction , ToggleOrSetOutputScrollLockAction . ID , ToggleOrSetOutputScrollLockAction . LABEL ) ,
70+ this . scopedInstantiationService . createInstance ( OpenLogOutputFile )
7071 ] ;
7172
7273 this . actions . forEach ( a => this . _register ( a ) ) ;
@@ -77,7 +78,7 @@ export class OutputPanel extends AbstractTextResourceEditor {
7778
7879 getActionViewItem ( action : Action ) : IActionViewItem | undefined {
7980 if ( action . id === SwitchOutputAction . ID ) {
80- return this . instantiationService . createInstance ( SwitchOutputActionViewItem , action ) ;
81+ return this . scopedInstantiationService . createInstance ( SwitchOutputActionViewItem , action ) ;
8182 }
8283
8384 return super . getActionViewItem ( action ) ;
@@ -95,7 +96,7 @@ export class OutputPanel extends AbstractTextResourceEditor {
9596 options . renderLineHighlight = 'none' ;
9697 options . minimap = { enabled : false } ;
9798
98- const outputConfig = this . baseConfigurationService . getValue < any > ( '[Log]' ) ;
99+ const outputConfig = this . configurationService . getValue < any > ( '[Log]' ) ;
99100 if ( outputConfig ) {
100101 if ( outputConfig [ 'editor.minimap.enabled' ] ) {
101102 options . minimap = { enabled : true } ;
@@ -115,17 +116,17 @@ export class OutputPanel extends AbstractTextResourceEditor {
115116 }
116117
117118 async setInput ( input : EditorInput , options : EditorOptions | undefined , token : CancellationToken ) : Promise < void > {
118- this . _focus = ! ( options && options . preserveFocus ) ;
119+ const focus = ! ( options && options . preserveFocus ) ;
119120 if ( input . matches ( this . input ) ) {
120- return Promise . resolve ( undefined ) ;
121+ return ;
121122 }
122123
123124 if ( this . input ) {
124125 // Dispose previous input (Output panel is not a workbench editor)
125126 this . input . dispose ( ) ;
126127 }
127128 await super . setInput ( input , options , token ) ;
128- if ( this . _focus ) {
129+ if ( focus ) {
129130 this . focus ( ) ;
130131 }
131132 this . revealLastLine ( ) ;
@@ -140,15 +141,17 @@ export class OutputPanel extends AbstractTextResourceEditor {
140141 }
141142
142143 protected createEditor ( parent : HTMLElement ) : void {
144+
143145 // First create the scoped instantiation service and only then construct the editor using the scoped service
144146 const scopedContextKeyService = this . _register ( this . contextKeyService . createScoped ( parent ) ) ;
145147 this . scopedInstantiationService = this . instantiationService . createChild ( new ServiceCollection ( [ IContextKeyService , scopedContextKeyService ] ) ) ;
148+
146149 super . createEditor ( parent ) ;
147150
148151 CONTEXT_IN_OUTPUT . bindTo ( scopedContextKeyService ) . set ( true ) ;
149152
150153 const codeEditor = < ICodeEditor > this . getControl ( ) ;
151- codeEditor . onDidChangeCursorPosition ( ( e ) => {
154+ this . _register ( codeEditor . onDidChangeCursorPosition ( ( e ) => {
152155 if ( e . reason !== CursorChangeReason . Explicit ) {
153156 return ;
154157 }
@@ -161,6 +164,6 @@ export class OutputPanel extends AbstractTextResourceEditor {
161164 const lockAction = this . actions . filter ( ( action ) => action . id === ToggleOrSetOutputScrollLockAction . ID ) [ 0 ] ;
162165 lockAction . run ( newLockState ) ;
163166 }
164- } ) ;
167+ } ) ) ;
165168 }
166169}
0 commit comments