33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { EditorInput , ITextEditorModel , IModeSupport , GroupIdentifier , isTextEditor } from 'vs/workbench/common/editor' ;
6+ import { ITextEditorModel , IModeSupport , TextEditorInput } from 'vs/workbench/common/editor' ;
77import { URI } from 'vs/base/common/uri' ;
88import { IReference } from 'vs/base/common/lifecycle' ;
99import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
1010import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel' ;
1111import { basename } from 'vs/base/common/resources' ;
12- import { ITextFileSaveOptions , ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
13- import { IEditorViewState } from 'vs/editor/common/editorCommon' ;
12+ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
1413import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
14+ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
1515
1616/**
1717 * A read-only text editor input whos contents are made of the provided resource that points to an existing
1818 * code editor model.
1919 */
20- export class ResourceEditorInput extends EditorInput implements IModeSupport {
20+ export class ResourceEditorInput extends TextEditorInput implements IModeSupport {
2121
2222 static readonly ID : string = 'workbench.editors.resourceEditorInput' ;
2323
@@ -27,17 +27,14 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
2727 constructor (
2828 private name : string | undefined ,
2929 private description : string | undefined ,
30- private readonly resource : URI ,
30+ resource : URI ,
3131 private preferredMode : string | undefined ,
3232 @ITextModelService private readonly textModelResolverService : ITextModelService ,
33- @ITextFileService private readonly textFileService : ITextFileService ,
34- @IEditorService private readonly editorService : IEditorService
33+ @ITextFileService textFileService : ITextFileService ,
34+ @IEditorService editorService : IEditorService ,
35+ @IEditorGroupsService editorGroupService : IEditorGroupsService
3536 ) {
36- super ( ) ;
37-
38- this . name = name ;
39- this . description = description ;
40- this . resource = resource ;
37+ super ( resource , editorService , editorGroupService , textFileService ) ;
4138 }
4239
4340 getResource ( ) : URI {
@@ -109,28 +106,6 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
109106 return model ;
110107 }
111108
112- async saveAs ( group : GroupIdentifier , options ?: ITextFileSaveOptions ) : Promise < boolean > {
113-
114- // Preserve view state by opening the editor first. In addition
115- // this allows the user to review the contents of the editor.
116- let viewState : IEditorViewState | undefined = undefined ;
117- const editor = await this . editorService . openEditor ( this , undefined , group ) ;
118- if ( isTextEditor ( editor ) ) {
119- viewState = editor . getViewState ( ) ;
120- }
121-
122- // Save as
123- const target = await this . textFileService . saveAs ( this . resource , undefined , options ) ;
124- if ( ! target ) {
125- return false ; // save cancelled
126- }
127-
128- // Open the target
129- await this . editorService . openEditor ( { resource : target , options : { viewState, pinned : true } } , group ) ;
130-
131- return true ;
132- }
133-
134109 matches ( otherInput : unknown ) : boolean {
135110 if ( super . matches ( otherInput ) === true ) {
136111 return true ;
0 commit comments