Skip to content

Commit

Permalink
more polish for #10739
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Nov 3, 2016
1 parent 6ec2a29 commit ccfb85d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 66 deletions.
43 changes: 0 additions & 43 deletions src/vs/workbench/browser/parts/editor/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,49 +467,6 @@ export function toEditorQuickOpenEntry(element: any): IEditorQuickOpenEntry {
return null;
}

export class SaveEditorAction extends Action {

public static ID = 'workbench.action.files.save';
public static LABEL = nls.localize('saveEditor', "Save Editor");

constructor(
id: string,
label: string,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(id, label, 'save-editor-action');
}

public run(context?: IEditorContext): TPromise<any> {
const position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;

// Save Active Editor
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditorInput();
if (activeEditor instanceof EditorInput) {
return activeEditor.save();
}
}

let input = context ? context.editor : null;
if (!input) {

// Get Editor at Position
const visibleEditors = this.editorService.getVisibleEditors();
if (visibleEditors[position]) {
input = visibleEditors[position].input;
}
}

if (input instanceof EditorInput) {
return input.save();
}

return TPromise.as(false);
}
}

export class CloseEditorAction extends Action {

public static ID = 'workbench.action.closeActiveEditor';
Expand Down
40 changes: 23 additions & 17 deletions src/vs/workbench/browser/parts/editor/media/tabstitle.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@
padding-left: 10px;
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button {
padding-right: 28px; /* make room for dirty indication when we are running without close button */
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty {
padding-right: 0; /* dirty tabs always show the dirty indicator, so we can clear the padding now */
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.active {
z-index: 2; /* on top of the horizontal border of the title */
}
Expand Down Expand Up @@ -183,10 +175,6 @@
display: none; /* hide the close action bar when we are configured to hide it */
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty > .tab-close {
display: block; /* show the close action bar when the tab gets dirty */
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title.active .tabs-container > .tab.active > .tab-close .action-label, /* always show it for active tab */
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title.active .tabs-container > .tab > .tab-close .action-label:focus, /* always show it on focus */
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title.active .tabs-container > .tab:hover > .tab-close .action-label, /* always show it on hover */
Expand Down Expand Up @@ -215,15 +203,12 @@
margin-right: 0.5em;
}

.vs .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .close-editor-action,
.vs .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .save-editor-action {
.vs .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .close-editor-action {
background: url('close-dirty.svg') center center no-repeat;
}

.vs-dark .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .close-editor-action,
.hc-black .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .close-editor-action,
.vs-dark .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .save-editor-action,
.hc-black .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .save-editor-action {
.hc-black .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dirty .close-editor-action {
background: url('close-dirty-inverse.svg') center center no-repeat;
}

Expand All @@ -236,6 +221,27 @@
background: url('close-inverse.svg') center center no-repeat;
}

/* No Tab Close Button */

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button {
padding-right: 28px; /* make room for dirty indication when we are running without close button */
}

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty {
background-repeat: no-repeat;
background-position-y: center;
background-position-x: calc(100% - 6px); /* to the right of the tab label */
}

.vs .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty {
background-image: url('close-dirty.svg');
}

.vs-dark .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty,
.hc-black .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.no-close-button.dirty {
background-image: url('close-dirty-inverse.svg');
}

/* Editor Actions */

.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .editor-actions {
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ export class TabsTitleControl extends TitleControl {
tabContainer.appendChild(tabCloseContainer);

const bar = new ActionBar(tabCloseContainer, { context: { editor, group }, ariaLabel: nls.localize('araLabelTabActions', "Tab actions") });
const action = this.showTabCloseButton ? this.closeEditorAction : this.saveEditorAction;
bar.push(action, { icon: true, label: false, keybinding: this.getKeybindingLabel(action) });
bar.push(this.closeEditorAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(this.closeEditorAction) });

this.tabDisposeables.push(bar);

Expand Down
5 changes: 1 addition & 4 deletions src/vs/workbench/browser/parts/editor/titleControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickO
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { Keybinding } from 'vs/base/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { CloseEditorsInGroupAction, SplitEditorAction, SaveEditorAction, CloseEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, CloseRightEditorsInGroupAction, ShowEditorsInGroupAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { CloseEditorsInGroupAction, SplitEditorAction, CloseEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, CloseRightEditorsInGroupAction, ShowEditorsInGroupAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
Expand Down Expand Up @@ -68,7 +68,6 @@ export abstract class TitleControl implements ITitleAreaControl {
protected dragged: boolean;

protected closeEditorAction: CloseEditorAction;
protected saveEditorAction: SaveEditorAction;
protected pinEditorAction: KeepEditorAction;
protected closeOtherEditorsAction: CloseOtherEditorsInGroupAction;
protected closeRightEditorsAction: CloseRightEditorsInGroupAction;
Expand Down Expand Up @@ -232,7 +231,6 @@ export abstract class TitleControl implements ITitleAreaControl {

private initActions(): void {
this.closeEditorAction = this.instantiationService.createInstance(CloseEditorAction, CloseEditorAction.ID, nls.localize('close', "Close"));
this.saveEditorAction = this.instantiationService.createInstance(SaveEditorAction, SaveEditorAction.ID, nls.localize('save', "Save"));
this.closeOtherEditorsAction = this.instantiationService.createInstance(CloseOtherEditorsInGroupAction, CloseOtherEditorsInGroupAction.ID, nls.localize('closeOthers', "Close Others"));
this.closeRightEditorsAction = this.instantiationService.createInstance(CloseRightEditorsInGroupAction, CloseRightEditorsInGroupAction.ID, nls.localize('closeRight', "Close to the Right"));
this.closeEditorsInGroupAction = this.instantiationService.createInstance(CloseEditorsInGroupAction, CloseEditorsInGroupAction.ID, nls.localize('closeAll', "Close All"));
Expand Down Expand Up @@ -495,7 +493,6 @@ export abstract class TitleControl implements ITitleAreaControl {
this.splitEditorAction,
this.showEditorsInGroupAction,
this.closeEditorAction,
this.saveEditorAction,
this.closeRightEditorsAction,
this.closeOtherEditorsAction,
this.closeEditorsInGroupAction,
Expand Down

0 comments on commit ccfb85d

Please sign in to comment.