diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 1b1a39b3..39c4275b 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -432,7 +432,7 @@ export class UnpinEditorAction extends Action { label: string, @ICommandService private readonly commandService: ICommandService ) { - super(id, label, ThemeIcon.asClassName(Codicon.pinned)); + super(id, label, ThemeIcon.asClassName(Codicon.starFull)); } override run(context?: IEditorCommandsContext): Promise { @@ -440,6 +440,24 @@ export class UnpinEditorAction extends Action { } } +export class PinEditorAction extends Action { + + static readonly ID = 'workbench.action.pinEditor'; + static readonly LABEL = localize('pinEditor', "Pin Editor"); + + constructor( + id: string, + label: string, + @ICommandService private readonly commandService: ICommandService + ) { + super(id, label, ThemeIcon.asClassName(Codicon.star)); + } + + override async run(context?: IEditorCommandsContext): Promise { + return this.commandService.executeCommand('workbench.action.pinEditor', undefined, context); + } +} + export class CloseEditorTabAction extends Action { static readonly ID = 'workbench.action.closeActiveEditor'; diff --git a/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css b/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css index 93559402..dd6c233f 100644 --- a/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css +++ b/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css @@ -385,7 +385,7 @@ .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.tab-actions-right.sizing-shrink > .tab-actions, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.tab-actions-right.sizing-fixed > .tab-actions { flex: 0; - overflow: hidden; /* let the tab actions be pushed out of view when sizing is set to shrink/fixed to make more room */ + overflow: visible; /* ensure tab actions are always visible */ } .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.dirty.tab-actions-right.sizing-shrink > .tab-actions, @@ -399,18 +399,8 @@ overflow: visible; /* ...but still show the tab actions on hover, focus and when dirty or sticky */ } -.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.close-action-off:not(.dirty) > .tab-actions, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sticky-compact > .tab-actions { - display: none; /* hide the tab actions when we are configured to hide it (unless dirty, but always when sticky-compact) */ -} - -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.active > .tab-actions .action-label, /* always show tab actions for active tab */ -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab > .tab-actions .action-label:focus, /* always show tab actions on focus */ -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab:hover > .tab-actions .action-label, /* always show tab actions on hover */ -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.active:hover > .tab-actions .action-label, /* always show tab actions on hover */ -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.sticky:not(.pinned-action-off) > .tab-actions .action-label, /* always show tab actions for sticky tabs */ -.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.dirty > .tab-actions .action-label { /* always show tab actions for dirty tabs */ - opacity: 1; + display: none; /* only hide tab actions when sticky-compact */ } .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-actions .actions-container { @@ -444,11 +434,11 @@ .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.dirty > .tab-actions .action-label, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sticky:not(.pinned-action-off) > .tab-actions .action-label, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab:hover > .tab-actions .action-label { - opacity: 0.5; /* show tab actions dimmed for inactive group */ + opacity: 1; } .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-actions .action-label { - opacity: 0; + opacity: 1; } /* Tab Actions: Off */ diff --git a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts index b23be82e..bbda32c4 100644 --- a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts @@ -35,7 +35,7 @@ import { MergeGroupMode, IMergeGroupOptions } from '../../../services/editor/com import { addDisposableListener, EventType, EventHelper, Dimension, scheduleAtNextAnimationFrame, findParentWithClass, clearNode, DragAndDropObserver, isMouseEvent, getWindow } from '../../../../base/browser/dom.js'; import { localize } from '../../../../nls.js'; import { IEditorGroupsView, EditorServiceImpl, IEditorGroupView, IInternalEditorOpenOptions, IEditorPartsView } from './editor.js'; -import { CloseEditorTabAction, UnpinEditorAction } from './editorActions.js'; +import { CloseEditorTabAction, PinEditorAction, UnpinEditorAction } from './editorActions.js'; import { assertAllDefined, assertIsDefined } from '../../../../base/common/types.js'; import { IEditorService } from '../../../services/editor/common/editorService.js'; import { basenameOrAuthority } from '../../../../base/common/resources.js'; @@ -113,6 +113,7 @@ export class MultiEditorTabsControl extends EditorTabsControl { private readonly closeEditorAction = this._register(this.instantiationService.createInstance(CloseEditorTabAction, CloseEditorTabAction.ID, CloseEditorTabAction.LABEL)); private readonly unpinEditorAction = this._register(this.instantiationService.createInstance(UnpinEditorAction, UnpinEditorAction.ID, UnpinEditorAction.LABEL)); + private readonly pinEditorAction = this._register(this.instantiationService.createInstance(PinEditorAction, PinEditorAction.ID, PinEditorAction.LABEL)); // Add this line private readonly tabResourceLabels = this._register(this.instantiationService.createInstance(ResourceLabels, DEFAULT_LABELS_CONTAINER)); private tabLabels: IEditorInputLabel[] = []; @@ -1518,28 +1519,28 @@ export class MultiEditorTabsControl extends EditorTabsControl { this.redrawTabLabel(editor, tabIndex, tabContainer, tabLabelWidget, tabLabel); // Action - const hasUnpinAction = isTabSticky && options.tabActionUnpinVisibility; - const hasCloseAction = !hasUnpinAction && options.tabActionCloseVisibility; - const hasAction = hasUnpinAction || hasCloseAction; + const hasCloseAction = options.tabActionCloseVisibility; + const hasAction = true; // Always show actions + // Determine which action to show let tabAction; - if (hasAction) { - tabAction = hasUnpinAction ? this.unpinEditorAction : this.closeEditorAction; + if (isTabSticky) { + tabAction = this.unpinEditorAction; } else { - // Even if the action is not visible, add it as it contains the dirty indicator - tabAction = isTabSticky ? this.unpinEditorAction : this.closeEditorAction; + tabAction = this.pinEditorAction; // Use pin action instead of close action } + // Update action bar if (!tabActionBar.hasAction(tabAction)) { if (!tabActionBar.isEmpty()) { tabActionBar.clear(); } - tabActionBar.push(tabAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(tabAction) }); } - tabContainer.classList.toggle(`pinned-action-off`, isTabSticky && !hasUnpinAction); - tabContainer.classList.toggle(`close-action-off`, !hasUnpinAction && !hasCloseAction); + tabContainer.classList.toggle('sticky', isTabSticky); + tabContainer.classList.toggle(`pinned-action-off`, false); + tabContainer.classList.toggle(`close-action-off`, !hasCloseAction); for (const option of ['left', 'right']) { tabContainer.classList.toggle(`tab-actions-${option}`, hasAction && options.tabActionLocation === option);