Skip to content

Commit 2dfec45

Browse files
author
Benjamin Pasero
committed
💄
1 parent ecdb907 commit 2dfec45

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

src/vs/workbench/parts/files/browser/fileActions.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Action, IAction } from 'vs/base/common/actions';
1010
import { isMacintosh } from 'vs/base/common/platform';
1111
import { ActionItem, BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
1212
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor } from 'vs/workbench/browser/actions';
13-
import { GlobalNewUntitledFileAction, SaveFileAsAction, OpenFileAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView, ShowModificationsAction } from 'vs/workbench/parts/files/browser/fileActions';
13+
import { GlobalNewUntitledFileAction, SaveFileAsAction, OpenFileAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView, CompareWithSavedAction } from 'vs/workbench/parts/files/browser/fileActions';
1414
import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTION_CONTEXT } from 'vs/workbench/parts/files/browser/saveErrorHandler';
1515
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
1616
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
@@ -207,7 +207,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAsAction, Save
207207
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewUntitledFileAction, GlobalNewUntitledFileAction.ID, GlobalNewUntitledFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_N }), 'Files: New Untitled File', category);
208208
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalRevealInOSAction, GlobalRevealInOSAction.ID, GlobalRevealInOSAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_R) }), 'Files: Reveal Active File', category);
209209
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowOpenedFileInNewWindow, ShowOpenedFileInNewWindow.ID, ShowOpenedFileInNewWindow.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_O) }), 'Files: Open Active File in New Window', category);
210-
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowModificationsAction, ShowModificationsAction.ID, ShowModificationsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_D) }), 'Files: Compare with Saved', category);
210+
registry.registerWorkbenchAction(new SyncActionDescriptor(CompareWithSavedAction, CompareWithSavedAction.ID, CompareWithSavedAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_D) }), 'Files: Compare Active File with Saved', category);
211211

212212
if (isMacintosh) {
213213
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileFolderAction, OpenFileFolderAction.ID, OpenFileFolderAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'Files: Open...', category);

src/vs/workbench/parts/files/browser/fileActions.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,10 +1999,12 @@ export function getWellFormedFileName(filename: string): string {
19991999
return filename;
20002000
}
20012001

2002-
export const SHOW_MODIFICATIONS_SCHEME = 'showModifications';
2003-
export class ShowModificationsAction extends Action implements ITextModelContentProvider {
2004-
public static ID = 'workbench.files.action.showModifications';
2005-
public static LABEL = nls.localize('showModifications', "Compare with Saved");
2002+
export class CompareWithSavedAction extends Action implements ITextModelContentProvider {
2003+
2004+
public static ID = 'workbench.files.action.compareWithSaved';
2005+
public static LABEL = nls.localize('compareWithSaved', "Compare Active File with Saved");
2006+
2007+
private static SCHEME = 'showModifications';
20062008

20072009
private resource: URI;
20082010

@@ -2019,7 +2021,7 @@ export class ShowModificationsAction extends Action implements ITextModelContent
20192021
) {
20202022
super(id, label);
20212023

2022-
textModelService.registerTextModelContentProvider(SHOW_MODIFICATIONS_SCHEME, this);
2024+
textModelService.registerTextModelContentProvider(CompareWithSavedAction.SCHEME, this);
20232025

20242026
this.enabled = true;
20252027
}
@@ -2030,7 +2032,6 @@ export class ShowModificationsAction extends Action implements ITextModelContent
20302032

20312033
public run(): TPromise<any> {
20322034
let resource: URI;
2033-
20342035
if (this.resource) {
20352036
resource = this.resource;
20362037
} else {
@@ -2040,13 +2041,15 @@ export class ShowModificationsAction extends Action implements ITextModelContent
20402041
if (resource && resource.scheme !== 'untitled') {
20412042
const name = paths.basename(resource.fsPath);
20422043
const editorLabel = nls.localize('modifiedLabel', "{0} (on disk) ↔ {1}", name, name);
2043-
return this.editorService.openEditor({ leftResource: URI.from({ scheme: SHOW_MODIFICATIONS_SCHEME, path: resource.fsPath }), rightResource: resource, label: editorLabel });
2044+
2045+
return this.editorService.openEditor({ leftResource: URI.from({ scheme: CompareWithSavedAction.SCHEME, path: resource.fsPath }), rightResource: resource, label: editorLabel });
20442046
}
20452047

20462048
return TPromise.as(true);
20472049
}
20482050

20492051
provideTextContent(resource: URI): TPromise<IModel> {
2052+
20502053
// Make sure our file from disk is resolved up to date
20512054
return this.textFileService.resolveTextContent(URI.file(resource.fsPath)).then(content => {
20522055
let codeEditorModel = this.modelService.getModel(resource);

src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { explorerItemToFileResource } from 'vs/workbench/parts/files/common/file
2828
import { ITextFileService, AutoSaveMode } from 'vs/workbench/services/textfile/common/textfiles';
2929
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
3030
import { EditorStacksModel, EditorGroup } from 'vs/workbench/common/editor/editorStacksModel';
31-
import { SaveFileAction, RevertFileAction, SaveFileAsAction, OpenToSideAction, SelectResourceForCompareAction, CompareResourcesAction, SaveAllInGroupAction, ShowModificationsAction } from 'vs/workbench/parts/files/browser/fileActions';
31+
import { SaveFileAction, RevertFileAction, SaveFileAsAction, OpenToSideAction, SelectResourceForCompareAction, CompareResourcesAction, SaveAllInGroupAction, CompareWithSavedAction } from 'vs/workbench/parts/files/browser/fileActions';
3232
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
3333
import { CloseOtherEditorsInGroupAction, CloseEditorAction, CloseEditorsInGroupAction, CloseUnmodifiedEditorsInGroupAction } from 'vs/workbench/browser/parts/editor/editorActions';
3434

@@ -396,10 +396,10 @@ export class ActionProvider extends ContributableActionProvider {
396396
// Compare Actions
397397
result.push(new Separator());
398398

399-
const showModificationsAction = this.instantiationService.createInstance(ShowModificationsAction, ShowModificationsAction.ID, ShowModificationsAction.LABEL);
400-
showModificationsAction.setResource(resource);
401-
showModificationsAction.enabled = openEditor.isDirty();
402-
result.push(showModificationsAction);
399+
const compareWithSavedAction = this.instantiationService.createInstance(CompareWithSavedAction, CompareWithSavedAction.ID, nls.localize('compareWithSaved', "Compare with Saved"));
400+
compareWithSavedAction.setResource(resource);
401+
compareWithSavedAction.enabled = openEditor.isDirty();
402+
result.push(compareWithSavedAction);
403403

404404
const runCompareAction = this.instantiationService.createInstance(CompareResourcesAction, resource, tree);
405405
if (runCompareAction._isEnabled()) {

0 commit comments

Comments
 (0)