diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 52acc7aced565a502b12e218654c8720df8be337..51a0464b43b1efde146799b5d17bff960eada98d 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -21,7 +21,7 @@ import { extractResources } from 'vs/base/browser/dnd'; import { Builder, $ } from 'vs/base/browser/builder'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { AutoSaveConfiguration } from 'vs/platform/files/common/files'; -import { toResource, EditorInput } from 'vs/workbench/common/editor'; +import { toResource } from 'vs/workbench/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IMessageService } from 'vs/platform/message/common/message'; @@ -29,7 +29,6 @@ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configurat import { IWindowsService, IWindowService, IWindowSettings } from 'vs/platform/windows/common/windows'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -45,7 +44,6 @@ import { ReloadWindowAction, ToggleDevToolsAction, ShowStartupPerformance, OpenR import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { DiffEditorInput, toDiffLabel } from 'vs/workbench/common/editor/diffEditorInput'; import { Position, IResourceInput } from 'vs/platform/editor/common/editor'; import { IExtensionService } from 'vs/platform/extensions/common/extensions'; @@ -91,7 +89,6 @@ export class ElectronWindow { @IContextMenuService private contextMenuService: IContextMenuService, @IKeybindingService private keybindingService: IKeybindingService, @IEnvironmentService private environmentService: IEnvironmentService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, ) { this.win = win; @@ -382,10 +379,8 @@ export class ElectronWindow { return this.partService.joinCreation().then(() => { // In diffMode we open 2 resources as diff - if (diffMode) { - return TPromise.join(resources.map(f => this.editorService.createInput(f))).then((inputs: EditorInput[]) => { - return this.editorService.openEditor(new DiffEditorInput(toDiffLabel(resources[0].resource, resources[1].resource, this.contextService), null, inputs[0], inputs[1])); - }); + if (diffMode && resources.length === 2) { + return this.editorService.openEditor({ leftResource: resources[0].resource, rightResource: resources[1].resource }); } // For one file, just put it into the current active editor diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index fcef52a3f3112e15d086ca74f1177cab5a9a9c9a..d13e9854d3fabe64f702a401294375223e9c3baf 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -38,7 +38,6 @@ import { WorkbenchLayout } from 'vs/workbench/browser/layout'; import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actionBarRegistry'; import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel'; import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController'; -import { DiffEditorInput, toDiffLabel } from 'vs/workbench/common/editor/diffEditorInput'; import { getServices } from 'vs/platform/instantiation/common/extensions'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { WorkbenchEditorService } from 'vs/workbench/services/editor/browser/editorService'; @@ -360,10 +359,8 @@ export class Workbench implements IPartService { const filesToDiff = wbopt.filesToDiff; // Files to diff is exclusive - if (filesToDiff && filesToDiff.length) { - return TPromise.join(filesToDiff.map(resourceInput => this.editorService.createInput(resourceInput))).then((inputsToDiff) => { - return [{ input: new DiffEditorInput(toDiffLabel(filesToDiff[0].resource, filesToDiff[1].resource, this.contextService), null, inputsToDiff[0], inputsToDiff[1]) }]; - }); + if (filesToDiff && filesToDiff.length === 2) { + return this.editorService.createInput({ leftResource: filesToDiff[0].resource, rightResource: filesToDiff[1].resource }).then(input => [{ input }]); } // Otherwise: Open/Create files diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index ec27cdc274c5bb50fb2815aa25cc6c2e69e96716..53ac33691996dd84805c40ff369adfcabb9ef621 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -26,7 +26,6 @@ import { VIEWLET_ID } from 'vs/workbench/parts/files/common/files'; import labels = require('vs/base/common/labels'); import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IFileService, IFileStat } from 'vs/platform/files/common/files'; -import { toDiffLabel } from 'vs/workbench/common/editor/diffEditorInput'; import { toResource, IEditorIdentifier, EditorInput } from 'vs/workbench/common/editor'; import { FileStat, NewStatPlaceholder } from 'vs/workbench/parts/files/common/explorerViewModel'; import { ExplorerView } from 'vs/workbench/parts/files/browser/views/explorerView'; @@ -1213,7 +1212,6 @@ export class CompareResourcesAction extends Action { constructor( resource: URI, tree: ITree, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IInstantiationService private instantiationService: IInstantiationService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService ) { @@ -1271,8 +1269,7 @@ export class CompareResourcesAction extends Action { return this.editorService.openEditor({ leftResource: globalResourceToCompare, - rightResource: this.resource, - label: toDiffLabel(globalResourceToCompare, this.resource, this.contextService) + rightResource: this.resource }); } } diff --git a/src/vs/workbench/parts/files/browser/saveErrorHandler.ts b/src/vs/workbench/parts/files/browser/saveErrorHandler.ts index dd18ce71bc180ad3d3de75f7e410c6917c5bd96e..8de0dfa8fc3da4c84b871650199e7f2305194e36 100644 --- a/src/vs/workbench/parts/files/browser/saveErrorHandler.ts +++ b/src/vs/workbench/parts/files/browser/saveErrorHandler.ts @@ -11,7 +11,6 @@ import { toErrorMessage } from 'vs/base/common/errorMessage'; import paths = require('vs/base/common/paths'); import { Action } from 'vs/base/common/actions'; import URI from 'vs/base/common/uri'; -import { ICommandService } from 'vs/platform/commands/common/commands'; import { EditorInputAction } from 'vs/workbench/browser/parts/editor/baseEditor'; import { SaveFileAsAction, RevertFileAction, SaveFileAction } from 'vs/workbench/parts/files/browser/fileActions'; import { IFileOperationResult, FileOperationResult } from 'vs/platform/files/common/files'; @@ -186,7 +185,6 @@ class ResolveSaveConflictMessage implements IMessageWithAction { @IMessageService private messageService: IMessageService, @IInstantiationService private instantiationService: IInstantiationService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @ICommandService commandService: ICommandService, @IEnvironmentService private environmentService: IEnvironmentService ) { this.model = model; @@ -204,7 +202,7 @@ class ResolveSaveConflictMessage implements IMessageWithAction { const name = paths.basename(resource.fsPath); const editorLabel = nls.localize('saveConflictDiffLabel', "{0} (on disk) ↔ {1} (in {2}) - Resolve save conflict", name, name, this.environmentService.appNameLong); - return commandService.executeCommand('_workbench.diff', [URI.from({ scheme: CONFLICT_RESOLUTION_SCHEME, path: resource.fsPath }), resource, editorLabel]).then(() => { + return this.editorService.openEditor({ leftResource: URI.from({ scheme: CONFLICT_RESOLUTION_SCHEME, path: resource.fsPath }), rightResource: resource, label: editorLabel }).then(() => { // We have to bring the model into conflict resolution mode to prevent subsequent save erros when the user makes edits this.model.setConflictResolutionMode(); diff --git a/src/vs/workbench/parts/search/browser/replaceService.ts b/src/vs/workbench/parts/search/browser/replaceService.ts index 1cd10066f91fd977f5f9f1d49941fdfcc88f36ea..f83aa7269deca627100401818f0fa82e7e19dd66 100644 --- a/src/vs/workbench/parts/search/browser/replaceService.ts +++ b/src/vs/workbench/parts/search/browser/replaceService.ts @@ -10,7 +10,6 @@ import URI from 'vs/base/common/uri'; import * as network from 'vs/base/common/network'; import { Disposable } from 'vs/base/common/lifecycle'; import { IReplaceService } from 'vs/workbench/parts/search/common/replace'; -import { EditorInput } from 'vs/workbench/common/editor'; import { IEditorService } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -18,7 +17,6 @@ import { Match, FileMatch, FileMatchOrMatch, ISearchWorkbenchService } from 'vs/ import { BulkEdit, IResourceEdit, createBulkEdit } from 'vs/editor/common/services/bulkEdit'; import { IProgressRunner } from 'vs/platform/progress/common/progress'; import { IDiffEditor } from 'vs/editor/browser/editorBrowser'; -import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; @@ -128,16 +126,23 @@ export class ReplaceService implements IReplaceService { public openReplacePreview(element: FileMatchOrMatch, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): TPromise { this.telemetryService.publicLog('replace.open.previewEditor'); const fileMatch = element instanceof Match ? element.parent() : element; - return this.createInput(fileMatch).then((editorInput) => { - this.editorService.openEditor(editorInput, { preserveFocus, pinned, revealIfVisible: true }) - .then(editor => { - this.updateReplacePreview(fileMatch).then(() => { - let editorControl = (editor.getControl()); - if (element instanceof Match) { - editorControl.revealLineInCenter(element.range().startLineNumber); - } - }); - }, errors.onUnexpectedError); + + return this.editorService.openEditor({ + leftResource: fileMatch.resource(), + rightResource: this.getReplacePreviewUri(fileMatch), + label: nls.localize('fileReplaceChanges', "{0} ↔ {1} (Replace Preview)", fileMatch.name(), fileMatch.name()), + options: { + preserveFocus, + pinned, + revealIfVisible: true + } + }).then(editor => { + this.updateReplacePreview(fileMatch).then(() => { + let editorControl = (editor.getControl()); + if (element instanceof Match) { + editorControl.revealLineInCenter(element.range().startLineNumber); + } + }); }, errors.onUnexpectedError); } @@ -168,13 +173,6 @@ export class ReplaceService implements IReplaceService { return resourceEdit; } - private createInput(fileMatch: FileMatch): TPromise { - return TPromise.join([this.editorService.createInput({ resource: fileMatch.resource() }), this.editorService.createInput({ resource: this.getReplacePreviewUri(fileMatch) })]) - .then(([left, right]) => { - return new DiffEditorInput(nls.localize('fileReplaceChanges', "{0} ↔ {1} (Replace Preview)", fileMatch.name(), fileMatch.name()), '', left, right); - }); - } - private getReplacePreviewUri(fileMatch: FileMatch): URI { return fileMatch.resource().with({ scheme: network.Schemas.internal, fragment: 'preview' }); } diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 7a9cf82c86ea919567b76213899703ddedea3cbc..38f8898a3ee22ada13bea99dc6b1128b353f5d70 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -138,9 +138,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { /** * Allow subclasses to implement their own behavior for opening editor (see below). */ - protected doOpenEditor(input: EditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; - protected doOpenEditor(input: EditorInput, options?: EditorOptions, position?: Position): TPromise; - protected doOpenEditor(input: EditorInput, options?: EditorOptions, arg3?: any): TPromise { + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, position?: Position): TPromise; + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, arg3?: any): TPromise { return this.editorPart.openEditor(input, options, arg3); } @@ -148,7 +148,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { public openEditors(editors: { input: IEditorInput, position: Position, options?: IEditorOptions }[]): TPromise; public openEditors(editors: any[]): TPromise { return TPromise.join(editors.map(editor => this.createInput(editor.input))).then(inputs => { - const typedInputs: { input: EditorInput, position: Position, options?: EditorOptions }[] = inputs.map((input, index) => { + const typedInputs: { input: IEditorInput, position: Position, options?: EditorOptions }[] = inputs.map((input, index) => { const options = editors[index].input instanceof EditorInput ? this.toOptions(editors[index].options) : TextEditorOptions.from(editors[index].input); return { @@ -163,11 +163,11 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { } public replaceEditors(editors: { toReplace: IResourceInput | IResourceDiffInput, replaceWith: IResourceInput | IResourceDiffInput }[]): TPromise; - public replaceEditors(editors: { toReplace: EditorInput, replaceWith: EditorInput, options?: IEditorOptions }[]): TPromise; + public replaceEditors(editors: { toReplace: IEditorInput, replaceWith: IEditorInput, options?: IEditorOptions }[]): TPromise; public replaceEditors(editors: any[]): TPromise { return TPromise.join(editors.map(editor => this.createInput(editor.toReplace))).then(toReplaceInputs => { return TPromise.join(editors.map(editor => this.createInput(editor.replaceWith))).then(replaceWithInputs => { - const typedReplacements: { toReplace: EditorInput, replaceWith: EditorInput, options?: EditorOptions }[] = editors.map((editor, index) => { + const typedReplacements: { toReplace: IEditorInput, replaceWith: IEditorInput, options?: EditorOptions }[] = editors.map((editor, index) => { const options = editor.toReplace instanceof EditorInput ? this.toOptions(editor.options) : TextEditorOptions.from(editor.replaceWith); return { @@ -194,7 +194,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { return this.editorPart.closeAllEditors(except); } - public createInput(input: EditorInput): TPromise; + public createInput(input: IEditorInput): TPromise; public createInput(input: IResourceInput | IResourceDiffInput): TPromise; public createInput(input: any): TPromise { @@ -250,8 +250,8 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { } export interface IDelegatingWorkbenchEditorServiceHandler { - (input: EditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; - (input: EditorInput, options?: EditorOptions, position?: Position): TPromise; + (input: IEditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; + (input: IEditorInput, options?: EditorOptions, position?: Position): TPromise; } /** @@ -281,9 +281,9 @@ export class DelegatingWorkbenchEditorService extends WorkbenchEditorService { this.handler = handler; } - protected doOpenEditor(input: EditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; - protected doOpenEditor(input: EditorInput, options?: EditorOptions, position?: Position): TPromise; - protected doOpenEditor(input: EditorInput, options?: EditorOptions, arg3?: any): TPromise { + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, sideBySide?: boolean): TPromise; + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, position?: Position): TPromise; + protected doOpenEditor(input: IEditorInput, options?: EditorOptions, arg3?: any): TPromise { return this.handler(input, options, arg3).then(editor => { if (editor) { return TPromise.as(editor);