44 *--------------------------------------------------------------------------------------------*/
55'use strict' ;
66
7- import { IModelService , shouldSynchronizeModel } from 'vs/editor/common/services/modelService' ;
8- import { ITextModel } from 'vs/editor/common/model' ;
9- import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
7+ import { Emitter , Event } from 'vs/base/common/event' ;
8+ import { dispose , IDisposable } from 'vs/base/common/lifecycle' ;
9+ import URI from 'vs/base/common/uri' ;
10+ import { ICodeEditor , isCodeEditor , isDiffEditor } from 'vs/editor/browser/editorBrowser' ;
11+ import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
1012import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
11- import { Event , Emitter } from 'vs/base/common/event' ;
12- import { ExtHostContext , ExtHostDocumentsAndEditorsShape , IModelAddedData , ITextEditorAddData , IDocumentsAndEditorsDelta , IExtHostContext , MainContext } from '../node/extHost.protocol' ;
13- import { MainThreadTextEditor } from './mainThreadEditor' ;
14- import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
15- import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService' ;
16- import { EditorViewColumn , editorGroupToViewColumn } from 'vs/workbench/api/shared/editor' ;
17- import { IEditor } from 'vs/workbench/common/editor' ;
13+ import { IEditor } from 'vs/editor/common/editorCommon' ;
14+ import { ITextModel } from 'vs/editor/common/model' ;
15+ import { IModelService , shouldSynchronizeModel } from 'vs/editor/common/services/modelService' ;
16+ import { IModeService } from 'vs/editor/common/services/modeService' ;
17+ import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
18+ import { IFileService } from 'vs/platform/files/common/files' ;
1819import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers' ;
1920import { MainThreadDocuments } from 'vs/workbench/api/electron-browser/mainThreadDocuments' ;
2021import { MainThreadTextEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors' ;
21- import { IModeService } from 'vs/editor/common/services/modeService' ;
22- import { IFileService } from 'vs/platform/files/common/files' ;
23- import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
24- import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService' ;
22+ import { editorGroupToViewColumn , EditorViewColumn } from 'vs/workbench/api/shared/editor' ;
23+ import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor' ;
24+ import { IEditor as IWorkbenchEditor } from 'vs/workbench/common/editor' ;
2525import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
26- import { isDiffEditor , ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
27- import URI from 'vs/base/common/uri' ;
28- import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
26+ import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService' ;
27+ import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
28+ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
29+ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService' ;
30+ import { ExtHostContext , ExtHostDocumentsAndEditorsShape , IDocumentsAndEditorsDelta , IExtHostContext , IModelAddedData , ITextEditorAddData , MainContext } from '../node/extHost.protocol' ;
31+ import { MainThreadTextEditor } from './mainThreadEditor' ;
2932
3033namespace mapset {
3134
@@ -161,7 +164,8 @@ class MainThreadDocumentAndEditorStateComputer {
161164 private readonly _onDidChangeState : ( delta : DocumentAndEditorStateDelta ) => void ,
162165 @IModelService private readonly _modelService : IModelService ,
163166 @ICodeEditorService private readonly _codeEditorService : ICodeEditorService ,
164- @IEditorService private readonly _editorService : IEditorService
167+ @IEditorService private readonly _editorService : IEditorService ,
168+ @IPanelService private readonly _panelService : IPanelService ,
165169 ) {
166170 this . _modelService . onModelAdded ( this . _updateStateOnModelAdd , this , this . _toDispose ) ;
167171 this . _modelService . onModelRemoved ( this . _updateState , this , this . _toDispose ) ;
@@ -252,13 +256,21 @@ class MainThreadDocumentAndEditorStateComputer {
252256 }
253257
254258 // active editor: if none of the previous editors had focus we try
255- // to match the active workbench editor with one of editor we have
256- // just computed
259+ // to match output panels or the the active workbench editor with
260+ // one of editor we have just computed
257261 if ( ! activeEditor ) {
258- let candidate = this . _editorService . activeTextEditorWidget ;
259- if ( isDiffEditor ( candidate ) ) {
260- candidate = candidate . getModifiedEditor ( ) ;
262+
263+ let candidate : IEditor ;
264+ let panel = this . _panelService . getActivePanel ( ) ;
265+ if ( panel instanceof BaseTextEditor && isCodeEditor ( panel . getControl ( ) ) ) {
266+ candidate = panel . getControl ( ) ;
267+ } else {
268+ candidate = this . _editorService . activeTextEditorWidget ;
269+ if ( isDiffEditor ( candidate ) ) {
270+ candidate = candidate . getModifiedEditor ( ) ;
271+ }
261272 }
273+
262274 if ( candidate ) {
263275 editors . forEach ( snapshot => {
264276 if ( candidate === snapshot . editor ) {
@@ -307,7 +319,8 @@ export class MainThreadDocumentsAndEditors {
307319 @ITextModelService textModelResolverService : ITextModelService ,
308320 @IUntitledEditorService untitledEditorService : IUntitledEditorService ,
309321 @IEditorGroupsService private readonly _editorGroupService : IEditorGroupsService ,
310- @IBulkEditService bulkEditService : IBulkEditService
322+ @IBulkEditService bulkEditService : IBulkEditService ,
323+ @IPanelService panelService : IPanelService
311324
312325 ) {
313326 this . _proxy = extHostContext . getProxy ( ExtHostContext . ExtHostDocumentsAndEditors ) ;
@@ -319,7 +332,7 @@ export class MainThreadDocumentsAndEditors {
319332 extHostContext . set ( MainContext . MainThreadTextEditors , mainThreadTextEditors ) ;
320333
321334 // It is expected that the ctor of the state computer calls our `_onDelta`.
322- this . _stateComputer = new MainThreadDocumentAndEditorStateComputer ( delta => this . _onDelta ( delta ) , _modelService , codeEditorService , this . _editorService ) ;
335+ this . _stateComputer = new MainThreadDocumentAndEditorStateComputer ( delta => this . _onDelta ( delta ) , _modelService , codeEditorService , this . _editorService , panelService ) ;
323336
324337 this . _toDispose = [
325338 mainThreadDocuments ,
@@ -430,7 +443,7 @@ export class MainThreadDocumentsAndEditors {
430443 return undefined ;
431444 }
432445
433- findTextEditorIdFor ( editor : IEditor ) : string {
446+ findTextEditorIdFor ( editor : IWorkbenchEditor ) : string {
434447 for ( let id in this . _textEditors ) {
435448 if ( this . _textEditors [ id ] . matches ( editor ) ) {
436449 return id ;
0 commit comments