diff --git a/src/vs/workbench/api/browser/mainThreadDocuments.ts b/src/vs/workbench/api/browser/mainThreadDocuments.ts index 7be61f10e10..dd345661531 100644 --- a/src/vs/workbench/api/browser/mainThreadDocuments.ts +++ b/src/vs/workbench/api/browser/mainThreadDocuments.ts @@ -8,7 +8,6 @@ import { IDisposable, IReference, dispose, DisposableStore } from 'vs/base/commo import { Schemas } from 'vs/base/common/network'; import { URI, UriComponents } from 'vs/base/common/uri'; import { ITextModel } from 'vs/editor/common/model'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { IFileService } from 'vs/platform/files/common/files'; @@ -16,7 +15,6 @@ import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/browser/mainThre import { ExtHostContext, ExtHostDocumentsShape, IExtHostContext, MainThreadDocumentsShape } from 'vs/workbench/api/common/extHost.protocol'; import { ITextEditorModel } from 'vs/workbench/common/editor'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { toLocalResource } from 'vs/base/common/resources'; @@ -70,7 +68,6 @@ export class MainThreadDocuments implements MainThreadDocumentsShape { private readonly _textModelResolverService: ITextModelService; private readonly _textFileService: ITextFileService; private readonly _fileService: IFileService; - private readonly _untitledTextEditorService: IUntitledTextEditorService; private readonly _environmentService: IWorkbenchEnvironmentService; private readonly _toDispose = new DisposableStore(); @@ -83,18 +80,15 @@ export class MainThreadDocuments implements MainThreadDocumentsShape { documentsAndEditors: MainThreadDocumentsAndEditors, extHostContext: IExtHostContext, @IModelService modelService: IModelService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService, @IFileService fileService: IFileService, @ITextModelService textModelResolverService: ITextModelService, - @IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService, @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService ) { this._modelService = modelService; this._textModelResolverService = textModelResolverService; this._textFileService = textFileService; this._fileService = fileService; - this._untitledTextEditorService = untitledTextEditorService; this._environmentService = environmentService; this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDocuments); @@ -222,7 +216,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape { } private _doCreateUntitled(resource?: URI, mode?: string, initialValue?: string): Promise { - return this._untitledTextEditorService.createOrGet({ + return this._textFileService.untitled.createOrGet({ resource, mode, initialValue, diff --git a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts index edc1470d929..e1401d465be 100644 --- a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts @@ -12,7 +12,6 @@ import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { IEditor } from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { IFileService } from 'vs/platform/files/common/files'; @@ -28,7 +27,6 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; namespace delta { @@ -324,10 +322,8 @@ export class MainThreadDocumentsAndEditors { @ITextFileService private readonly _textFileService: ITextFileService, @IEditorService private readonly _editorService: IEditorService, @ICodeEditorService codeEditorService: ICodeEditorService, - @IModeService modeService: IModeService, @IFileService fileService: IFileService, @ITextModelService textModelResolverService: ITextModelService, - @IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService, @IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService, @IBulkEditService bulkEditService: IBulkEditService, @IPanelService panelService: IPanelService, @@ -335,7 +331,7 @@ export class MainThreadDocumentsAndEditors { ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDocumentsAndEditors); - const mainThreadDocuments = this._toDispose.add(new MainThreadDocuments(this, extHostContext, this._modelService, modeService, this._textFileService, fileService, textModelResolverService, untitledTextEditorService, environmentService)); + const mainThreadDocuments = this._toDispose.add(new MainThreadDocuments(this, extHostContext, this._modelService, this._textFileService, fileService, textModelResolverService, environmentService)); extHostContext.set(MainContext.MainThreadDocuments, mainThreadDocuments); const mainThreadTextEditors = this._toDispose.add(new MainThreadTextEditors(this, extHostContext, codeEditorService, bulkEditService, this._editorService, this._editorGroupService)); diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts index 10d6cf85ef7..0597360f5ec 100644 --- a/src/vs/workbench/browser/dnd.ts +++ b/src/vs/workbench/browser/dnd.ts @@ -12,7 +12,6 @@ import { URI } from 'vs/base/common/uri'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; import { Schemas } from 'vs/base/common/network'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { DefaultEndOfLine } from 'vs/editor/common/model'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IEditorViewState } from 'vs/editor/common/editorCommon'; @@ -171,7 +170,6 @@ export class ResourcesDropHandler { @IWorkspacesService private readonly workspacesService: IWorkspacesService, @ITextFileService private readonly textFileService: ITextFileService, @IBackupFileService private readonly backupFileService: IBackupFileService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, @IEditorService private readonly editorService: IEditorService, @IConfigurationService private readonly configurationService: IConfigurationService, @IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService, @@ -244,7 +242,7 @@ export class ResourcesDropHandler { // Untitled: always ensure that we open a new untitled for each file we drop if (droppedDirtyEditor.resource.scheme === Schemas.untitled) { - droppedDirtyEditor.resource = this.untitledTextEditorService.createOrGet(undefined, droppedDirtyEditor.mode, undefined, droppedDirtyEditor.encoding).getResource(); + droppedDirtyEditor.resource = this.textFileService.untitled.createOrGet(undefined, droppedDirtyEditor.mode, undefined, droppedDirtyEditor.encoding).getResource(); } // Return early if the resource is already dirty in target or opened already @@ -352,7 +350,6 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources: // Editors: enables cross window DND of tabs into the editor area const textFileService = accessor.get(ITextFileService); - const untitledTextEditorService = accessor.get(IUntitledTextEditorService); const backupFileService = accessor.get(IBackupFileService); const editorService = accessor.get(IEditorService); @@ -375,8 +372,8 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources: // Try to find encoding and mode from text model let encoding: string | undefined = undefined; let mode: string | undefined = undefined; - if (untitledTextEditorService.exists(file.resource)) { - const model = untitledTextEditorService.createOrGet(file.resource); + if (textFileService.untitled.exists(file.resource)) { + const model = textFileService.untitled.createOrGet(file.resource); encoding = model.getEncoding(); mode = model.getMode(); } else { diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index 4052bcf0d8b..a16297036b1 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -13,7 +13,7 @@ import { PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IDecorationsService, IResourceDecorationChangeEvent } from 'vs/workbench/services/decorations/browser/decorations'; import { Schemas } from 'vs/base/common/network'; import { FileKind, FILES_ASSOCIATIONS_CONFIG, IFileService } from 'vs/platform/files/common/files'; @@ -260,7 +260,7 @@ class ResourceLabelWidget extends IconLabel { @IModelService private readonly modelService: IModelService, @IDecorationsService private readonly decorationsService: IDecorationsService, @ILabelService private readonly labelService: ILabelService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService private readonly textFileService: ITextFileService, @IWorkspaceContextService private readonly contextService: IWorkspaceContextService ) { super(container, options); @@ -390,7 +390,7 @@ class ResourceLabelWidget extends IconLabel { } let description: string | undefined; - const hidePath = (options && options.hidePath) || (resource.scheme === Schemas.untitled && !this.untitledTextEditorService.hasAssociatedFilePath(resource)); + const hidePath = (options && options.hidePath) || (resource.scheme === Schemas.untitled && !this.textFileService.untitled.hasAssociatedFilePath(resource)); if (!hidePath) { description = this.labelService.getUriLabel(resources.dirname(resource), { relative: true }); } diff --git a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts index e6992216ebb..450ad7aefeb 100644 --- a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +++ b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts @@ -18,7 +18,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { RunOnceScheduler } from 'vs/base/common/async'; import { find } from 'vs/base/common/arrays'; import { DataTransfers } from 'vs/base/browser/dnd'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { VSBuffer } from 'vs/base/common/buffer'; import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; import { URI } from 'vs/base/common/uri'; @@ -48,7 +48,7 @@ class DropOverlay extends Themable { private groupView: IEditorGroupView, @IThemeService themeService: IThemeService, @IInstantiationService private instantiationService: IInstantiationService, - @IUntitledTextEditorService private untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService private textFileService: ITextFileService, @IFileDialogService private readonly fileDialogService: IFileDialogService ) { super(themeService); @@ -309,7 +309,7 @@ class DropOverlay extends Themable { // Open as untitled file with the provided contents const contents = VSBuffer.wrap(new Uint8Array(event.target.result)).toString(); - const untitledEditor = this.untitledTextEditorService.createOrGet(proposedFilePath, undefined, contents); + const untitledEditor = this.textFileService.untitled.createOrGet(proposedFilePath, undefined, contents); if (!targetGroup) { targetGroup = ensureTargetGroup(); diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index fd6d2e95511..ec6b180d8d5 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -32,7 +32,7 @@ import { RunOnceWorker } from 'vs/base/common/async'; import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch'; import { TitleControl } from 'vs/workbench/browser/parts/editor/titleControl'; import { IEditorGroupsAccessor, IEditorGroupView, getActiveTextEditorOptions, IEditorOpeningEvent } from 'vs/workbench/browser/parts/editor/editor'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ActionRunner, IAction, Action } from 'vs/base/common/actions'; @@ -129,7 +129,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { @INotificationService private readonly notificationService: INotificationService, @IDialogService private readonly dialogService: IDialogService, @ITelemetryService private readonly telemetryService: ITelemetryService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService private readonly textFileService: ITextFileService, @IKeybindingService private readonly keybindingService: IKeybindingService, @IMenuService private readonly menuService: IMenuService, @IContextMenuService private readonly contextMenuService: IContextMenuService, @@ -256,7 +256,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { if (this.isEmpty) { EventHelper.stop(e); - this.openEditor(this.untitledTextEditorService.createOrGet(), EditorOptions.create({ pinned: true })); + this.openEditor(this.textFileService.untitled.createOrGet(), EditorOptions.create({ pinned: true })); } })); diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 90644f3691f..341267a99bf 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -15,7 +15,6 @@ import { Language } from 'vs/base/common/platform'; import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput'; import { IFileEditorInput, EncodingMode, IEncodingSupport, toResource, SideBySideEditorInput, IEditor as IBaseEditor, IEditorInput, SideBySideEditor, IModeSupport } from 'vs/workbench/common/editor'; import { Disposable, MutableDisposable, DisposableStore } from 'vs/base/common/lifecycle'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { IEditorAction } from 'vs/editor/common/editorCommon'; import { EndOfLineSequence } from 'vs/editor/common/model'; import { IModelLanguageChangedEvent, IModelOptionsChangedEvent } from 'vs/editor/common/model/textModelEvents'; @@ -296,7 +295,6 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { constructor( @IEditorService private readonly editorService: IEditorService, @IQuickInputService private readonly quickInputService: IQuickInputService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, @IModeService private readonly modeService: IModeService, @ITextFileService private readonly textFileService: ITextFileService, @IConfigurationService private readonly configurationService: IConfigurationService, @@ -313,7 +311,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { private registerListeners(): void { this._register(this.editorService.onDidActiveEditorChange(() => this.updateStatusBar())); - this._register(this.untitledTextEditorService.onDidChangeEncoding(r => this.onResourceEncodingChange(r))); + this._register(this.textFileService.untitled.onDidChangeEncoding(r => this.onResourceEncodingChange(r))); this._register(this.textFileService.models.onDidChangeEncoding(m => this.onResourceEncodingChange((m.resource)))); this._register(TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange())); } @@ -1001,7 +999,7 @@ export class ChangeModeAction extends Action { @IQuickInputService private readonly quickInputService: IQuickInputService, @IPreferencesService private readonly preferencesService: IPreferencesService, @IInstantiationService private readonly instantiationService: IInstantiationService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService + @ITextFileService private readonly textFileService: ITextFileService ) { super(actionId, actionLabel); } @@ -1016,7 +1014,7 @@ export class ChangeModeAction extends Action { const resource = this.editorService.activeEditor ? toResource(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER }) : null; let hasLanguageSupport = !!resource; - if (resource?.scheme === Schemas.untitled && !this.untitledTextEditorService.hasAssociatedFilePath(resource)) { + if (resource?.scheme === Schemas.untitled && !this.textFileService.untitled.hasAssociatedFilePath(resource)) { hasLanguageSupport = false; // no configuration for untitled resources (e.g. "Untitled-1") } diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index 6011bbc2f45..5dd389484f1 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -32,7 +32,6 @@ import { Color } from 'vs/base/common/color'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { MergeGroupMode, IMergeGroupOptions, GroupsArrangement } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { addClass, addDisposableListener, hasClass, EventType, EventHelper, removeClass, Dimension, scheduleAtNextAnimationFrame, findParentWithClass, clearNode } from 'vs/base/browser/dom'; import { localize } from 'vs/nls'; import { IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'; @@ -42,6 +41,7 @@ import { BreadcrumbsControl } from 'vs/workbench/browser/parts/editor/breadcrumb import { IFileService } from 'vs/platform/files/common/files'; import { withNullAsUndefined, assertAllDefined, assertIsDefined } from 'vs/base/common/types'; import { ILabelService } from 'vs/platform/label/common/label'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; interface IEditorInputLabel { name?: string; @@ -74,7 +74,7 @@ export class TabsTitleControl extends TitleControl { group: IEditorGroupView, @IContextMenuService contextMenuService: IContextMenuService, @IInstantiationService instantiationService: IInstantiationService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService private readonly textFileService: ITextFileService, @IContextKeyService contextKeyService: IContextKeyService, @IKeybindingService keybindingService: IKeybindingService, @ITelemetryService telemetryService: ITelemetryService, @@ -192,7 +192,7 @@ export class TabsTitleControl extends TitleControl { EventHelper.stop(e); - this.group.openEditor(this.untitledTextEditorService.createOrGet(), { pinned: true /* untitled is always pinned */, index: this.group.count /* always at the end */ }); + this.group.openEditor(this.textFileService.untitled.createOrGet(), { pinned: true /* untitled is always pinned */, index: this.group.count /* always at the end */ }); })); }); diff --git a/src/vs/workbench/contrib/backup/test/electron-browser/backupRestorer.test.ts b/src/vs/workbench/contrib/backup/test/electron-browser/backupRestorer.test.ts index 832375b29dc..f665b1d7c5e 100644 --- a/src/vs/workbench/contrib/backup/test/electron-browser/backupRestorer.test.ts +++ b/src/vs/workbench/contrib/backup/test/electron-browser/backupRestorer.test.ts @@ -16,7 +16,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile import { hashPath } from 'vs/workbench/services/backup/node/backupFileService'; import { BackupTracker } from 'vs/workbench/contrib/backup/common/backupTracker'; import { TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { BackupRestorer } from 'vs/workbench/contrib/backup/common/backupRestorer'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -54,8 +53,7 @@ class TestBackupRestorer extends BackupRestorer { class ServiceAccessor { constructor( - @ITextFileService public textFileService: TestTextFileService, - @IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService + @ITextFileService public textFileService: TestTextFileService ) { } } @@ -129,12 +127,12 @@ suite('BackupRestorer', () => { for (const editor of editorService.editors) { const resource = editor.getResource(); if (isEqual(resource, untitledFile1)) { - const model = await accessor.untitledTextEditorService.createOrGet(resource).resolve(); + const model = await accessor.textFileService.untitled.createOrGet(resource).resolve(); assert.equal(model.textEditorModel.getValue(), 'untitled-1'); model.dispose(); counter++; } else if (isEqual(resource, untitledFile2)) { - const model = await accessor.untitledTextEditorService.createOrGet(resource).resolve(); + const model = await accessor.textFileService.untitled.createOrGet(resource).resolve(); assert.equal(model.textEditorModel.getValue(), 'untitled-2'); model.dispose(); counter++; diff --git a/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts b/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts index 7c61a061a8c..248401f1f72 100644 --- a/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts +++ b/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts @@ -14,7 +14,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile import { hashPath } from 'vs/workbench/services/backup/node/backupFileService'; import { BackupTracker } from 'vs/workbench/contrib/backup/common/backupTracker'; import { TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart'; @@ -44,7 +43,6 @@ const workspaceBackupPath = path.join(backupHome, hashPath(workspaceResource)); class ServiceAccessor { constructor( @ITextFileService public textFileService: TestTextFileService, - @IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService, @IEditorService public editorService: IEditorService, @IBackupFileService public backupFileService: NodeTestBackupFileService ) { @@ -125,7 +123,7 @@ suite('BackupTracker', () => { const [accessor, part, tracker] = await createTracker(); - const untitledEditor = accessor.untitledTextEditorService.createOrGet(); + const untitledEditor = accessor.textFileService.untitled.createOrGet(); await accessor.editorService.openEditor(untitledEditor, { pinned: true }); const untitledModel = await untitledEditor.resolve(); diff --git a/src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts b/src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts index ff6bdf9920b..20b7a62eddc 100644 --- a/src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts +++ b/src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts @@ -25,7 +25,6 @@ import { timeout, RunOnceWorker } from 'vs/base/common/async'; import { withNullAsUndefined } from 'vs/base/common/types'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { isEqualOrParent, joinPath } from 'vs/base/common/resources'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; export class FileEditorTracker extends Disposable implements IWorkbenchContribution { @@ -41,8 +40,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut @IConfigurationService private readonly configurationService: IConfigurationService, @IWorkspaceContextService private readonly contextService: IWorkspaceContextService, @IHostService private readonly hostService: IHostService, - @ICodeEditorService private readonly codeEditorService: ICodeEditorService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService + @ICodeEditorService private readonly codeEditorService: ICodeEditorService ) { super(); @@ -62,7 +60,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut // Ensure dirty text file and untitled models are always opened as editors this._register(this.textFileService.models.onDidChangeDirty(m => this.ensureDirtyFilesAreOpenedWorker.work(m.resource))); this._register(this.textFileService.models.onDidSaveError(m => this.ensureDirtyFilesAreOpenedWorker.work(m.resource))); - this._register(this.untitledTextEditorService.onDidChangeDirty(r => this.ensureDirtyFilesAreOpenedWorker.work(r))); + this._register(this.textFileService.untitled.onDidChangeDirty(r => this.ensureDirtyFilesAreOpenedWorker.work(r))); // Out of workspace file watchers this._register(this.editorService.onDidVisibleEditorsChange(() => this.onDidVisibleEditorsChange())); diff --git a/src/vs/workbench/contrib/files/test/browser/editorAutoSave.test.ts b/src/vs/workbench/contrib/files/test/browser/editorAutoSave.test.ts index 8bdc754410f..cf8f9e0ed82 100644 --- a/src/vs/workbench/contrib/files/test/browser/editorAutoSave.test.ts +++ b/src/vs/workbench/contrib/files/test/browser/editorAutoSave.test.ts @@ -21,7 +21,6 @@ import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileE import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart'; import { EditorService } from 'vs/workbench/services/editor/browser/editorService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { EditorAutoSave } from 'vs/workbench/browser/parts/editor/editorAutoSave'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; @@ -35,7 +34,6 @@ class ServiceAccessor { @IEditorGroupsService public editorGroupService: IEditorGroupsService, @ITextFileService public textFileService: TestTextFileService, @IFileService public fileService: TestFileService, - @IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService, @IConfigurationService public configurationService: TestConfigurationService ) { } diff --git a/src/vs/workbench/contrib/files/test/browser/fileEditorTracker.test.ts b/src/vs/workbench/contrib/files/test/browser/fileEditorTracker.test.ts index d69f586eee0..9197c258b81 100644 --- a/src/vs/workbench/contrib/files/test/browser/fileEditorTracker.test.ts +++ b/src/vs/workbench/contrib/files/test/browser/fileEditorTracker.test.ts @@ -23,15 +23,13 @@ import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileE import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart'; import { EditorService } from 'vs/workbench/services/editor/browser/editorService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; class ServiceAccessor { constructor( @IEditorService public editorService: IEditorService, @IEditorGroupsService public editorGroupService: IEditorGroupsService, @ITextFileService public textFileService: TestTextFileService, - @IFileService public fileService: TestFileService, - @IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService + @IFileService public fileService: TestFileService ) { } } @@ -125,7 +123,7 @@ suite('Files - FileEditorTracker', () => { test('dirty untitled text file model opens as editor', async function () { const [part, accessor, tracker] = await createTracker(); - const untitledEditor = accessor.untitledTextEditorService.createOrGet(); + const untitledEditor = accessor.textFileService.untitled.createOrGet(); const model = await untitledEditor.resolve(); assert.ok(!accessor.editorService.isOpen(untitledEditor)); diff --git a/src/vs/workbench/contrib/search/browser/searchEditorCommands.ts b/src/vs/workbench/contrib/search/browser/searchEditorCommands.ts index 431fb547cb5..f01dd38d815 100644 --- a/src/vs/workbench/contrib/search/browser/searchEditorCommands.ts +++ b/src/vs/workbench/contrib/search/browser/searchEditorCommands.ts @@ -31,7 +31,6 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { SearchEditor } from 'vs/workbench/contrib/search/browser/searchEditor'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { ITextFileSaveOptions, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import type { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput'; import { dirname, joinPath, isEqual } from 'vs/base/common/resources'; @@ -142,7 +141,6 @@ export class SearchEditorInput extends EditorInput { @IEditorService protected readonly editorService: IEditorService, @IEditorGroupsService protected readonly editorGroupService: IEditorGroupsService, @ITextFileService protected readonly textFileService: ITextFileService, - @IUntitledTextEditorService protected readonly untitledTextEditorService: IUntitledTextEditorService, @IHistoryService private readonly historyService: IHistoryService, @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IFileDialogService private readonly fileDialogService: IFileDialogService, diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 1e50712e3c5..73c7284d25a 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -53,7 +53,7 @@ import { getOutOfWorkspaceEditorResources } from 'vs/workbench/contrib/search/co import { FileMatch, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService, Match, RenderableMatch, searchMatchComparer, SearchModel, SearchResult, FolderMatch, FolderMatchWithResource } from 'vs/workbench/contrib/search/common/searchModel'; import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { IPreferencesService, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { relativePath } from 'vs/base/common/resources'; import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer'; @@ -162,7 +162,7 @@ export class SearchView extends ViewPane { @ISearchWorkbenchService private readonly searchWorkbenchService: ISearchWorkbenchService, @IContextKeyService private readonly contextKeyService: IContextKeyService, @IReplaceService private readonly replaceService: IReplaceService, - @IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService private readonly textFileService: ITextFileService, @IPreferencesService private readonly preferencesService: IPreferencesService, @IThemeService protected themeService: IThemeService, @ISearchHistoryService private readonly searchHistoryService: ISearchHistoryService, @@ -214,7 +214,7 @@ export class SearchView extends ViewPane { this.viewletState = this.memento.getMemento(StorageScope.WORKSPACE); this._register(this.fileService.onFileChanges(e => this.onFilesChanged(e))); - this._register(this.untitledTextEditorService.onDidDisposeModel(e => this.onUntitledDidDispose(e))); + this._register(this.textFileService.untitled.onDidDisposeModel(e => this.onUntitledDidDispose(e))); this._register(this.contextService.onDidChangeWorkbenchState(() => this.onDidChangeWorkbenchState())); this._register(this.searchHistoryService.onDidClearHistory(() => this.clearHistory())); diff --git a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts index 793f2fe3b72..0a97cdb6fb4 100644 --- a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts @@ -38,7 +38,6 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor import { KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'; -import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { TestBackupFileService, TestContextService, TestEditorGroupsService, TestEditorService, TestLifecycleService, TestTextFileService, TestTextResourcePropertiesService, TestWorkingCopyService } from 'vs/workbench/test/workbenchTestServices'; import { FileService } from 'vs/platform/files/common/fileService'; import { Schemas } from 'vs/base/common/network'; @@ -105,7 +104,6 @@ suite.skip('KeybindingsEditing', () => { fileService.registerProvider(Schemas.file, diskFileSystemProvider); fileService.registerProvider(Schemas.userData, new FileUserDataProvider(environmentService.appSettingsHome, environmentService.backupHome, diskFileSystemProvider, environmentService)); instantiationService.stub(IFileService, fileService); - instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService)); instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService)); instantiationService.stub(ITextModelService, instantiationService.createInstance(TextModelResolverService)); instantiationService.stub(IBackupFileService, new TestBackupFileService()); diff --git a/src/vs/workbench/services/search/common/searchService.ts b/src/vs/workbench/services/search/common/searchService.ts index 5b1223b5974..50e0b2e4745 100644 --- a/src/vs/workbench/services/search/common/searchService.ts +++ b/src/vs/workbench/services/search/common/searchService.ts @@ -19,7 +19,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { deserializeSearchError, FileMatch, ICachedSearchStats, IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, ISearchComplete, ISearchEngineStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, ITextQuery, pathIncludedInQuery, QueryType, SearchError, SearchErrorCode, SearchProviderType, isFileMatch, isProgressMessage } from 'vs/workbench/services/search/common/search'; import { addContextToEditorMatches, editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class SearchService extends Disposable implements ISearchService { @@ -32,7 +32,7 @@ export class SearchService extends Disposable implements ISearchService { constructor( private readonly modelService: IModelService, - private readonly untitledTextEditorService: IUntitledTextEditorService, + private readonly textFileService: ITextFileService, private readonly editorService: IEditorService, private readonly telemetryService: ITelemetryService, private readonly logService: ILogService, @@ -403,7 +403,7 @@ export class SearchService extends Disposable implements ISearchService { // Support untitled files if (resource.scheme === Schemas.untitled) { - if (!this.untitledTextEditorService.exists(resource)) { + if (!this.textFileService.untitled.exists(resource)) { return; } } @@ -457,14 +457,14 @@ export class SearchService extends Disposable implements ISearchService { export class RemoteSearchService extends SearchService { constructor( @IModelService modelService: IModelService, - @IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService textFileService: ITextFileService, @IEditorService editorService: IEditorService, @ITelemetryService telemetryService: ITelemetryService, @ILogService logService: ILogService, @IExtensionService extensionService: IExtensionService, @IFileService fileService: IFileService ) { - super(modelService, untitledTextEditorService, editorService, telemetryService, logService, extensionService, fileService); + super(modelService, textFileService, editorService, telemetryService, logService, extensionService, fileService); } } diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 112134ad703..5b730237b01 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -21,7 +21,7 @@ import { SearchChannelClient } from './searchIpc'; import { SearchService } from 'vs/workbench/services/search/common/searchService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; @@ -31,7 +31,7 @@ import { parseSearchPort } from 'vs/platform/environment/node/environmentService export class LocalSearchService extends SearchService { constructor( @IModelService modelService: IModelService, - @IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService, + @ITextFileService textFileService: ITextFileService, @IEditorService editorService: IEditorService, @ITelemetryService telemetryService: ITelemetryService, @ILogService logService: ILogService, @@ -40,7 +40,7 @@ export class LocalSearchService extends SearchService { @IWorkbenchEnvironmentService readonly environmentService: IWorkbenchEnvironmentService, @IInstantiationService readonly instantiationService: IInstantiationService ) { - super(modelService, untitledTextEditorService, editorService, telemetryService, logService, extensionService, fileService); + super(modelService, textFileService, editorService, telemetryService, logService, extensionService, fileService); this.diskSearch = instantiationService.createInstance(DiskSearch, !environmentService.isBuilt || environmentService.verbose, parseSearchPort(environmentService.args, environmentService.isBuilt)); diff --git a/src/vs/workbench/services/textfile/browser/textFileService.ts b/src/vs/workbench/services/textfile/browser/textFileService.ts index c6a829ede18..69b05c812e4 100644 --- a/src/vs/workbench/services/textfile/browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/browser/textFileService.ts @@ -13,7 +13,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IFileService, FileOperationError, FileOperationResult, IFileStatWithMetadata, ICreateFileOptions, FileOperation } from 'vs/platform/files/common/files'; import { Disposable } from 'vs/base/common/lifecycle'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; +import { IUntitledTextEditorService, IUntitledTextEditorModelManager } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { UntitledTextEditorModel } from 'vs/workbench/common/editor/untitledTextEditorModel'; import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -56,11 +56,16 @@ export abstract class AbstractTextFileService extends Disposable implements ITex readonly models = this._register(this.instantiationService.createInstance(TextFileEditorModelManager)); + private _untitled: IUntitledTextEditorModelManager; + get untitled(): IUntitledTextEditorModelManager { + return this._untitled; + } + abstract get encoding(): IResourceEncodings; constructor( @IFileService protected readonly fileService: IFileService, - @IUntitledTextEditorService protected readonly untitledTextEditorService: IUntitledTextEditorService, + @IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService, @ILifecycleService protected readonly lifecycleService: ILifecycleService, @IInstantiationService protected readonly instantiationService: IInstantiationService, @IModeService private readonly modeService: IModeService, @@ -76,6 +81,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex ) { super(); + this._untitled = untitledTextEditorService; + this.registerListeners(); } @@ -293,11 +300,11 @@ export abstract class AbstractTextFileService extends Disposable implements ITex // Untitled if (resource.scheme === Schemas.untitled) { - if (this.untitledTextEditorService.exists(resource)) { + if (this.untitled.exists(resource)) { let targetUri: URI | undefined; // Untitled with associated file path don't need to prompt - if (this.untitledTextEditorService.hasAssociatedFilePath(resource)) { + if (this.untitled.hasAssociatedFilePath(resource)) { targetUri = toLocalResource(resource, this.environmentService.configuration.remoteAuthority); } @@ -595,7 +602,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex } private suggestFileName(untitledResource: URI): URI { - const untitledFileName = this.untitledTextEditorService.exists(untitledResource) ? this.untitledTextEditorService.createOrGet(untitledResource).suggestFileName() : basename(untitledResource); + const untitledFileName = this.untitled.exists(untitledResource) ? this.untitled.createOrGet(untitledResource).suggestFileName() : basename(untitledResource); const remoteAuthority = this.environmentService.configuration.remoteAuthority; const schemeFilter = remoteAuthority ? Schemas.vscodeRemote : Schemas.file; @@ -620,8 +627,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex async revert(resource: URI, options?: IRevertOptions): Promise { // Untitled - if (this.untitledTextEditorService.exists(resource)) { - return this.untitledTextEditorService.createOrGet(resource).revert(options); + if (this.untitled.exists(resource)) { + return this.untitled.createOrGet(resource).revert(options); } // File @@ -678,7 +685,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex } // Check for dirty untitled - return this.untitledTextEditorService.exists(resource) && this.untitledTextEditorService.createOrGet(resource).isDirty(); + return this.untitled.exists(resource) && this.untitled.createOrGet(resource).isDirty(); } //#endregion diff --git a/src/vs/workbench/services/textfile/common/textfiles.ts b/src/vs/workbench/services/textfile/common/textfiles.ts index f505df3e772..60d82cc654c 100644 --- a/src/vs/workbench/services/textfile/common/textfiles.ts +++ b/src/vs/workbench/services/textfile/common/textfiles.ts @@ -15,6 +15,7 @@ import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer'; import { isUndefinedOrNull } from 'vs/base/common/types'; import { isNative } from 'vs/base/common/platform'; import { IWorkingCopy } from 'vs/workbench/services/workingCopy/common/workingCopyService'; +import { IUntitledTextEditorModelManager } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; export const ITextFileService = createDecorator('textFileService'); @@ -33,10 +34,17 @@ export interface ITextFileService extends IDisposable { readonly onDidRunOperation: Event; /** - * Access to the manager of text file editor models providing further methods to work with them. + * Access to the manager of text file editor models providing further + * methods to work with them. */ readonly models: ITextFileEditorModelManager; + /** + * Access to the manager of untitled text editor models providing further + * methods to work with them. + */ + readonly untitled: IUntitledTextEditorModelManager; + /** * Helper to determine encoding for resources. */ diff --git a/src/vs/workbench/services/textfile/test/textFileService.test.ts b/src/vs/workbench/services/textfile/test/textFileService.test.ts index 9a2eb29def1..c7af5c2b3c4 100644 --- a/src/vs/workbench/services/textfile/test/textFileService.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileService.test.ts @@ -11,7 +11,6 @@ import { toResource } from 'vs/base/test/common/utils'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { IFileService } from 'vs/platform/files/common/files'; import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -27,7 +26,6 @@ class ServiceAccessor { @ILifecycleService public lifecycleService: TestLifecycleService, @ITextFileService public textFileService: TestTextFileService, @IFilesConfigurationService public filesConfigurationService: TestFilesConfigurationService, - @IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService, @IWorkspaceContextService public contextService: TestContextService, @IModelService public modelService: ModelServiceImpl, @IFileService public fileService: TestFileService, @@ -66,7 +64,7 @@ suite('Files - TextFileService', () => { assert.ok(accessor.textFileService.isDirty(model.resource)); - const untitled = accessor.untitledTextEditorService.createOrGet(); + const untitled = accessor.textFileService.untitled.createOrGet(); const untitledModel = await untitled.resolve(); assert.ok(!accessor.textFileService.isDirty(untitled.getResource())); @@ -99,8 +97,8 @@ suite('Files - TextFileService', () => { const mockedEditorInput = instantiationService.createInstance(TextFileEditorModel, mockedFileUri, 'utf8', undefined); const loadOrCreateStub = sinon.stub(accessor.textFileService.models, 'loadOrCreate', () => Promise.resolve(mockedEditorInput)); - sinon.stub(accessor.untitledTextEditorService, 'exists', () => true); - sinon.stub(accessor.untitledTextEditorService, 'hasAssociatedFilePath', () => true); + sinon.stub(accessor.textFileService.untitled, 'exists', () => true); + sinon.stub(accessor.textFileService.untitled, 'hasAssociatedFilePath', () => true); sinon.stub(accessor.modelService, 'updateModel', () => { }); await model.load(); diff --git a/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts b/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts index 21c2a60093e..10dcaae1f7c 100644 --- a/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts +++ b/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts @@ -25,9 +25,7 @@ export interface IUntitledCreationOptions { useResourcePath?: boolean; } -export interface IUntitledTextEditorService { - - _serviceBrand: undefined; +export interface IUntitledTextEditorModelManager { /** * Events for when untitled text editors change (e.g. getting dirty, saved or reverted). @@ -65,6 +63,11 @@ export interface IUntitledTextEditorService { hasAssociatedFilePath(resource: URI): boolean; } +export interface IUntitledTextEditorService extends IUntitledTextEditorModelManager { + + _serviceBrand: undefined; +} + export class UntitledTextEditorService extends Disposable implements IUntitledTextEditorService { _serviceBrand: undefined; diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts index 12d00d9f733..1eea992bc81 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts @@ -69,10 +69,8 @@ suite('MainThreadDocumentsAndEditors', () => { textFileService, workbenchEditorService, codeEditorService, - null!, fileService, null!, - null!, editorGroupService, null!, new class extends mock() implements IPanelService { diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 8e7888ba8ce..65298911bda 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -112,10 +112,8 @@ suite('MainThreadEditors', () => { textFileService, workbenchEditorService, codeEditorService, - null!, fileService, null!, - null!, editorGroupService, bulkEditService, new class extends mock() implements IPanelService {