55
66import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
77import { IResourceInput , ITextEditorOptions , IEditorOptions , EditorActivation } from 'vs/platform/editor/common/editor' ;
8- import { IEditorInput , IEditor , GroupIdentifier , IFileEditorInput , IUntitledTextResourceInput , IResourceDiffInput , IResourceSideBySideInput , IEditorInputFactoryRegistry , Extensions as EditorExtensions , IFileInputFactory , EditorInput , SideBySideEditorInput , IEditorInputWithOptions , isEditorInputWithOptions , EditorOptions , TextEditorOptions , IEditorIdentifier , IEditorCloseEvent , ITextEditor , ITextDiffEditor , ITextSideBySideEditor , toResource , SideBySideEditor , IRevertOptions , SaveReason } from 'vs/workbench/common/editor' ;
8+ import { IEditorInput , IEditor , GroupIdentifier , IFileEditorInput , IUntitledTextResourceInput , IResourceDiffInput , IResourceSideBySideInput , IEditorInputFactoryRegistry , Extensions as EditorExtensions , IFileInputFactory , EditorInput , SideBySideEditorInput , IEditorInputWithOptions , isEditorInputWithOptions , EditorOptions , TextEditorOptions , IEditorIdentifier , IEditorCloseEvent , ITextEditor , ITextDiffEditor , ITextSideBySideEditor , toResource , SideBySideEditor , IRevertOptions , SaveReason , EditorsOrder } from 'vs/workbench/common/editor' ;
99import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput' ;
1010import { Registry } from 'vs/platform/registry/common/platform' ;
1111import { ResourceMap } from 'vs/base/common/map' ;
@@ -17,7 +17,7 @@ import { URI } from 'vs/base/common/uri';
1717import { basename , isEqual } from 'vs/base/common/resources' ;
1818import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput' ;
1919import { localize } from 'vs/nls' ;
20- import { IEditorGroupsService , IEditorGroup , GroupsOrder , IEditorReplacement , GroupChangeKind , preferredSideBySideGroupDirection , EditorsOrder } from 'vs/workbench/services/editor/common/editorGroupsService' ;
20+ import { IEditorGroupsService , IEditorGroup , GroupsOrder , IEditorReplacement , GroupChangeKind , preferredSideBySideGroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService' ;
2121import { IResourceEditor , SIDE_GROUP , IResourceEditorReplacement , IOpenEditorOverrideHandler , IVisibleEditor , IEditorService , SIDE_GROUP_TYPE , ACTIVE_GROUP_TYPE , ISaveEditorsOptions , ISaveAllEditorsOptions , IRevertAllEditorsOptions , IBaseSaveRevertAllEditorOptions } from 'vs/workbench/services/editor/common/editorService' ;
2222import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2323import { Disposable , IDisposable , dispose , toDisposable , DisposableStore } from 'vs/base/common/lifecycle' ;
@@ -186,19 +186,28 @@ export class EditorService extends Disposable implements EditorServiceImpl {
186186 return undefined ;
187187 }
188188
189+ get count ( ) : number {
190+ return this . editorsObserver . count ;
191+ }
192+
189193 get editors ( ) : IEditorInput [ ] {
190- const editors : IEditorInput [ ] = [ ] ;
191- this . editorGroupService . groups . forEach ( group => {
192- editors . push ( ...group . editors ) ;
194+ return this . getEditors ( EditorsOrder . SEQUENTIAL ) . map ( ( { editor } ) => editor ) ;
195+ }
196+
197+ getEditors ( order : EditorsOrder ) : ReadonlyArray < IEditorIdentifier > {
198+ if ( order === EditorsOrder . MOST_RECENTLY_ACTIVE ) {
199+ return this . editorsObserver . editors ;
200+ }
201+
202+ const editors : IEditorIdentifier [ ] = [ ] ;
203+
204+ this . editorGroupService . getGroups ( GroupsOrder . GRID_APPEARANCE ) . forEach ( group => {
205+ editors . push ( ...group . getEditors ( EditorsOrder . SEQUENTIAL ) . map ( editor => ( { editor, groupId : group . id } ) ) ) ;
193206 } ) ;
194207
195208 return editors ;
196209 }
197210
198- get mostRecentlyActiveEditors ( ) : IEditorIdentifier [ ] {
199- return this . editorsObserver . editors ;
200- }
201-
202211 get activeEditor ( ) : IEditorInput | undefined {
203212 const activeGroup = this . editorGroupService . activeGroup ;
204213
@@ -834,6 +843,9 @@ export class DelegatingEditorService implements IEditorService {
834843 get visibleControls ( ) : ReadonlyArray < IVisibleEditor > { return this . editorService . visibleControls ; }
835844 get visibleTextEditorWidgets ( ) : ReadonlyArray < ICodeEditor | IDiffEditor > { return this . editorService . visibleTextEditorWidgets ; }
836845 get editors ( ) : ReadonlyArray < IEditorInput > { return this . editorService . editors ; }
846+ get count ( ) : number { return this . editorService . count ; }
847+
848+ getEditors ( order : EditorsOrder ) : ReadonlyArray < IEditorIdentifier > { return this . editorService . getEditors ( order ) ; }
837849
838850 openEditors ( editors : IEditorInputWithOptions [ ] , group ?: OpenInEditorGroup ) : Promise < IEditor [ ] > ;
839851 openEditors ( editors : IResourceEditor [ ] , group ?: OpenInEditorGroup ) : Promise < IEditor [ ] > ;
0 commit comments