Skip to content

Commit

Permalink
Renaming Close Unmodified to Close Unsaved (#44269)
Browse files Browse the repository at this point in the history
* Renaming Close Unmodified to Close Unsaved
#44033

* Putting back action identifiers
  • Loading branch information
Itamar authored and bpasero committed Feb 26, 2018
1 parent d0ebe4e commit 3f6df1e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/editor/editor.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,19 @@ if (isMacintosh) {
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_EDITOR_COMMAND_ID, title: nls.localize('close', "Close") }, group: '1_close', order: 10 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeOthers', "Close Others") }, group: '1_close', order: 20 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID, title: nls.localize('closeRight', "Close to the Right") }, group: '1_close', order: 30, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeAllUnmodified', "Close Unmodified") }, group: '1_close', order: 40 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeAllSaved', "Close Saved") }, group: '1_close', order: 40 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.CLOSE_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeAll', "Close All") }, group: '1_close', order: 50 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.KEEP_EDITOR_COMMAND_ID, title: nls.localize('keepOpen', "Keep Open") }, group: '3_preview', order: 10, when: ContextKeyExpr.has('config.workbench.editor.enablePreview') });

// Editor Title Menu
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.TOGGLE_DIFF_INLINE_MODE, title: nls.localize('toggleInlineView', "Toggle Inline View") }, group: '1_diff', order: 10, when: ContextKeyExpr.has('isInDiffEditor') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.SHOW_EDITORS_IN_GROUP, title: nls.localize('showOpenedEditors', "Show Opened Editors") }, group: '3_open', order: 10, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.CLOSE_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeAll', "Close All") }, group: '5_close', order: 10, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeAllUnmodified', "Close Unmodified") }, group: '5_close', order: 20, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeAllSaved', "Close Saved") }, group: '5_close', order: 20, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });

// Editor Commands for Command Palette
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.KEEP_EDITOR_COMMAND_ID, title: nls.localize('keepEditor', "Keep Editor"), category }, when: ContextKeyExpr.has('config.workbench.editor.enablePreview') });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.CLOSE_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeEditorsInGroup', "Close All Editors in Group"), category } });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeUnmodifiedEditors', "Close Unmodified Editors in Group"), category } });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, title: nls.localize('closeSavedEditors', "Close Saved Editors in Group"), category } });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeOtherEditors', "Close Other Editors"), category } });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorCommands.CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID, title: nls.localize('closeRightEditors', "Close Editors to the Right"), category } });
14 changes: 7 additions & 7 deletions src/vs/workbench/browser/parts/editor/editorCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IListService } from 'vs/platform/list/browser/listService';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { distinct } from 'vs/base/common/arrays';

export const CLOSE_UNMODIFIED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors';
export const CLOSE_UNMODIFIED_EDITORS_COMMAND_ID = 'workbench.action.closeSavedEditors';
export const CLOSE_EDITORS_IN_GROUP_COMMAND_ID = 'workbench.action.closeEditorsInGroup';
export const CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID = 'workbench.action.closeEditorsToTheRight';
export const CLOSE_EDITOR_COMMAND_ID = 'workbench.action.closeActiveEditor';
Expand Down Expand Up @@ -279,14 +279,14 @@ function registerEditorCommands() {
contexts.push({ groupId: model.activeGroup.id });
}

let positionOne: { unmodifiedOnly: boolean } = void 0;
let positionTwo: { unmodifiedOnly: boolean } = void 0;
let positionThree: { unmodifiedOnly: boolean } = void 0;
let positionOne: { savedOnly: boolean } = void 0;
let positionTwo: { savedOnly: boolean } = void 0;
let positionThree: { savedOnly: boolean } = void 0;
contexts.forEach(c => {
switch (model.positionOfGroup(model.getGroup(c.groupId))) {
case Position.ONE: positionOne = { unmodifiedOnly: true }; break;
case Position.TWO: positionTwo = { unmodifiedOnly: true }; break;
case Position.THREE: positionThree = { unmodifiedOnly: true }; break;
case Position.ONE: positionOne = { savedOnly: true }; break;
case Position.TWO: positionTwo = { savedOnly: true }; break;
case Position.THREE: positionThree = { savedOnly: true }; break;
}
});

Expand Down
18 changes: 9 additions & 9 deletions src/vs/workbench/browser/parts/editor/editorPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ interface IEditorReplacement extends EditorIdentifier {
options?: EditorOptions;
}

export type ICloseEditorsFilter = { except?: EditorInput, direction?: Direction, unmodifiedOnly?: boolean };
export type ICloseEditorsFilter = { except?: EditorInput, direction?: Direction, savedOnly?: boolean };
export type ICloseEditorsByFilterArgs = { positionOne?: ICloseEditorsFilter, positionTwo?: ICloseEditorsFilter, positionThree?: ICloseEditorsFilter };
export type ICloseEditorsArgs = { positionOne?: EditorInput[], positionTwo?: EditorInput[], positionThree?: EditorInput[] };

Expand Down Expand Up @@ -828,8 +828,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
editorsToClose = group.getEditors(true /* in MRU order */);
filter = filterOrEditors || Object.create(null);

// Filter: unmodified only
if (filter.unmodifiedOnly) {
// Filter: saved only
if (filter.savedOnly) {
editorsToClose = editorsToClose.filter(e => !e.isDirty());
}

Expand Down Expand Up @@ -874,14 +874,14 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
}

private doCloseEditorsWithFilter(group: EditorGroup, filter: { except?: EditorInput, direction?: Direction, unmodifiedOnly?: boolean }): void {
private doCloseEditorsWithFilter(group: EditorGroup, filter: { except?: EditorInput, direction?: Direction, savedOnly?: boolean }): void {

// Close all editors if there is no editor to except and
// we either are not only closing unmodified editors or
// we either are not only closing saved editors or
// there are no dirty editors.
let closeAllEditors = false;
if (!filter.except) {
if (!filter.unmodifiedOnly) {
if (!filter.savedOnly) {
closeAllEditors = true;
} else {
closeAllEditors = !group.getEditors().some(e => e.isDirty());
Expand All @@ -893,10 +893,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this.doCloseAllEditorsInGroup(group);
}

// Close unmodified editors in group
else if (filter.unmodifiedOnly) {
// Close saved editors in group
else if (filter.savedOnly) {

// We can just close all unmodified editors around the currently active dirty one
// We can just close all saved editors around the currently active dirty one
if (group.activeEditor.isDirty()) {
group.getEditors().filter(editor => !editor.isDirty() && !editor.matches(filter.except)).forEach(editor => this.doCloseInactiveEditor(group, editor));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
order: 30,
command: {
id: CLOSE_UNMODIFIED_EDITORS_COMMAND_ID,
title: nls.localize('closeUnmodified', "Close Unmodified")
title: nls.localize('closeSaved', "Close Saved")
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/services/editor/common/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const IWorkbenchEditorService = createDecorator<IWorkbenchEditorService>(

export type IResourceInputType = IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput;

export type ICloseEditorsFilter = { except?: IEditorInput, direction?: Direction, unmodifiedOnly?: boolean };
export type ICloseEditorsFilter = { except?: IEditorInput, direction?: Direction, savedOnly?: boolean };

/**
* The editor service allows to open editors and work on the active
Expand Down

0 comments on commit 3f6df1e

Please sign in to comment.