1- import '../missing-services'
2- import { IEditorOverrideServices , StandaloneServices } from 'vs/editor/standalone/browser/standaloneServices'
3- import { IResolvedTextEditorModel , ITextModelService } from 'vs/editor/common/services/resolverService'
1+ import { IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices'
2+ import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService'
43import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'
54import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEditorService'
6- import { IEditorService , IEditorsChangeEvent , IOpenEditorsOptions , IRevertAllEditorsOptions , ISaveAllEditorsOptions , ISaveEditorsOptions , ISaveEditorsResult , IUntypedEditorReplacement , PreferredGroup } from 'vs/workbench/services/editor/common/editorService'
7- import { EditorExtensions , EditorInputWithOptions , EditorsOrder , GroupIdentifier , IEditorCloseEvent , IEditorIdentifier , IFindEditorOptions , IRevertOptions , IVisibleEditorPane } from 'vs/workbench/common/editor'
8- import type { IEditorFactoryRegistry , IEditorPane , IFileEditorInput , IResourceDiffEditorInput , ITextDiffEditorPane , IUntitledTextResourceEditorInput , IUntypedEditorInput } from 'vs/workbench/common/editor'
9- import { Emitter , Event } from 'vs/base/common/event'
10- import { EditorInput } from 'vs/workbench/common/editor/editorInput'
11- import { IEditorOptions , IResourceEditorInput , IResourceEditorInputIdentifier , ITextResourceEditorInput } from 'vs/platform/editor/common/editor'
12- import { IEditor } from 'vs/editor/common/editorCommon'
5+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService'
6+ import { EditorExtensions , IEditorFactoryRegistry , IFileEditorInput } from 'vs/workbench/common/editor'
7+ import { IEditorOptions } from 'vs/platform/editor/common/editor'
138import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'
14- import { Disposable , IReference } from 'vs/base/common/lifecycle'
15- import { ICodeEditor , IDiffEditor } from 'vs/editor/browser/editorBrowser'
9+ import { IReference } from 'vs/base/common/lifecycle'
1610import { ITextEditorService , TextEditorService } from 'vs/workbench/services/textfile/common/textEditorService'
17- import { ICloseEditorOptions , IEditorGroup , IEditorReplacement } from 'vs/workbench/services/editor/common/editorGroupsService'
18- import { URI } from 'vs/base/common/uri'
1911import { Registry } from 'vs/platform/registry/common/platform'
2012import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files'
21- import { OpenEditor , wrapOpenEditor } from './tools/editor'
13+ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'
14+ import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'
15+ import { MonacoDelegateEditorGroupsService , MonacoEditorService , OpenEditor } from './tools/editor'
2216import { unsupported } from '../tools'
17+ import { EmptyEditorGroupsService } from '../missing-services'
2318import 'vs/workbench/browser/parts/editor/editor.contribution'
2419
25- class SimpleEditorService extends Disposable implements IEditorService {
26- public activeTextEditorControl : IEditor | undefined
27- private _onDidActiveEditorChange = this . _register ( new Emitter < void > ( ) )
28-
29- constructor (
30- _openEditor : OpenEditor ,
31- @ITextModelService textModelService : ITextModelService
32- ) {
33- super ( )
34-
35- setTimeout ( ( ) => {
36- const codeEditorService = StandaloneServices . get ( ICodeEditorService )
37- this . activeTextEditorControl = codeEditorService . getFocusedCodeEditor ( ) ?? undefined
38- const handleCodeEditor = ( editor : ICodeEditor ) => {
39- const onEditorFocused = ( ) => {
40- const newFocusedEditor = codeEditorService . getFocusedCodeEditor ( )
41- if ( newFocusedEditor !== this . activeTextEditorControl ) {
42- this . activeTextEditorControl = newFocusedEditor ?? undefined
43- this . _onDidActiveEditorChange . fire ( )
44- }
45- }
46- editor . onDidFocusEditorText ( onEditorFocused )
47- editor . onDidFocusEditorWidget ( onEditorFocused )
48- }
49- this . _register ( codeEditorService . onCodeEditorAdd ( handleCodeEditor ) )
50- codeEditorService . listCodeEditors ( ) . forEach ( handleCodeEditor )
51- } )
52-
53- this . openEditor = wrapOpenEditor ( textModelService , this . openEditor . bind ( this ) , _openEditor )
20+ class MonacoEditorGroupsService extends MonacoDelegateEditorGroupsService < EmptyEditorGroupsService > {
21+ constructor ( @IInstantiationService instantiationService : IInstantiationService ) {
22+ super (
23+ instantiationService . createInstance ( EmptyEditorGroupsService ) ,
24+ instantiationService
25+ )
5426 }
55-
56- readonly _serviceBrand : undefined
57- onDidActiveEditorChange : Event < void > = this . _onDidActiveEditorChange . event
58- onDidVisibleEditorsChange : Event < void > = Event . None
59- onDidEditorsChange : Event < IEditorsChangeEvent > = Event . None
60- onDidCloseEditor : Event < IEditorCloseEvent > = Event . None
61- activeEditorPane : IVisibleEditorPane | undefined
62- activeEditor : EditorInput | undefined
63- activeTextEditorLanguageId : string | undefined
64- visibleEditorPanes : IVisibleEditorPane [ ] = [ ]
65- visibleEditors : EditorInput [ ] = [ ]
66- visibleTextEditorControls : Array < IEditor | IDiffEditor > = [ ]
67- editors : EditorInput [ ] = [ ]
68- count : number = 0
69- getEditors : ( order : EditorsOrder , options ?: { excludeSticky ?: boolean } ) => readonly IEditorIdentifier [ ] = ( ) => [ ]
70-
71- openEditor ( editor : EditorInput , options ?: IEditorOptions , group ?: PreferredGroup ) : Promise < IEditorPane | undefined >
72- openEditor ( editor : IUntypedEditorInput , group ?: PreferredGroup ) : Promise < IEditorPane | undefined >
73- openEditor ( editor : IResourceEditorInput , group ?: PreferredGroup ) : Promise < IEditorPane | undefined >
74- openEditor ( editor : ITextResourceEditorInput | IUntitledTextResourceEditorInput , group ?: PreferredGroup ) : Promise < IEditorPane | undefined >
75- openEditor ( editor : IResourceDiffEditorInput , group ?: PreferredGroup ) : Promise < ITextDiffEditorPane | undefined >
76- openEditor ( editor : EditorInput | IUntypedEditorInput , optionsOrPreferredGroup ?: IEditorOptions | PreferredGroup , preferredGroup ?: PreferredGroup ) : Promise < IEditorPane | undefined >
77- async openEditor ( _editor : EditorInput | IUntypedEditorInput , _optionsOrPreferredGroup ?: IEditorOptions | PreferredGroup , _preferredGroup ?: PreferredGroup ) : Promise < IEditorPane | undefined > {
78- return undefined
79- }
80-
81- openEditors : ( editors : Array < EditorInputWithOptions | IUntypedEditorInput > , preferredGroup ?: PreferredGroup , options ?: IOpenEditorsOptions ) => Promise < IEditorPane [ ] > = unsupported
82- replaceEditors : ( replacements : Array < IEditorReplacement | IUntypedEditorReplacement > , group : IEditorGroup | GroupIdentifier ) => Promise < void > = unsupported
83- isOpened : ( editor : IResourceEditorInputIdentifier ) => boolean = ( ) => false
84- isVisible : ( editor : EditorInput ) => boolean = ( ) => false
85- findEditors ( resource : URI , options ?: IFindEditorOptions ) : readonly IEditorIdentifier [ ]
86- findEditors ( editor : IResourceEditorInputIdentifier , options ?: IFindEditorOptions ) : readonly IEditorIdentifier [ ]
87- findEditors ( ) : readonly IEditorIdentifier [ ] { return [ ] }
88- save : ( editors : IEditorIdentifier | IEditorIdentifier [ ] , options ?: ISaveEditorsOptions ) => Promise < ISaveEditorsResult > = async ( ) => ( { success : true , editors : [ ] } )
89- saveAll : ( options ?: ISaveAllEditorsOptions ) => Promise < ISaveEditorsResult > = async ( ) => ( { success : true , editors : [ ] } )
90- revert : ( editors : IEditorIdentifier | IEditorIdentifier [ ] , options ?: IRevertOptions ) => Promise < boolean > = unsupported
91- revertAll : ( options ?: IRevertAllEditorsOptions ) => Promise < boolean > = unsupported
92- closeEditor : ( editor : IEditorIdentifier , options ?: ICloseEditorOptions ) => Promise < void > = unsupported
93- closeEditors : ( editors : readonly IEditorIdentifier [ ] , options ?: ICloseEditorOptions ) => Promise < void > = unsupported
9427}
9528
9629/**
@@ -106,8 +39,9 @@ Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFile
10639export default function getServiceOverride ( openEditor : OpenEditor ) : IEditorOverrideServices {
10740 return {
10841 [ ICodeEditorService . toString ( ) ] : new SyncDescriptor ( CodeEditorService , undefined , true ) ,
109- [ IEditorService . toString ( ) ] : new SyncDescriptor ( SimpleEditorService , [ openEditor ] , true ) ,
110- [ ITextEditorService . toString ( ) ] : new SyncDescriptor ( TextEditorService , [ ] , false )
42+ [ IEditorService . toString ( ) ] : new SyncDescriptor ( MonacoEditorService , [ openEditor , ( ) => false ] , true ) ,
43+ [ ITextEditorService . toString ( ) ] : new SyncDescriptor ( TextEditorService , [ ] , false ) ,
44+ [ IEditorGroupsService . toString ( ) ] : new SyncDescriptor ( MonacoEditorGroupsService )
11145 }
11246}
11347
@@ -116,5 +50,5 @@ export {
11650 IEditorOptions ,
11751 IResolvedTextEditorModel ,
11852 IReference ,
119- SimpleEditorService
53+ MonacoEditorService
12054}
0 commit comments