Skip to content

Commit

Permalink
ensure view containers don't unpin themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Mar 1, 2022
1 parent 54242ed commit f39b1f7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 3 additions & 5 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { ConfirmDialog, confirmExit, Dialog } from './dialogs';
import { WindowService } from './window/window-service';
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';
import { DecorationStyle } from './decoration-style';
import { Title, Widget } from './widgets';
import { PINNED_CLASS, Title, Widget } from './widgets';

export namespace CommonMenus {

Expand Down Expand Up @@ -327,8 +327,6 @@ export const supportPaste = browser.isNative || (!browser.isChrome && document.q

export const RECENT_COMMANDS_STORAGE_KEY = 'commands';

export const PINNED_CLASS = 'theia-mod-pinned';

@injectable()
export class CommonFrontendContribution implements FrontendApplicationContribution, MenuContribution, CommandContribution, KeybindingContribution, ColorContribution {

Expand Down Expand Up @@ -912,11 +910,11 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
execute: () => this.selectIconTheme()
});
commandRegistry.registerCommand(CommonCommands.PIN_TAB, new CurrentWidgetCommandAdapter(this.shell, {
isEnabled: title => !!title && title.closable && title.className.indexOf(PINNED_CLASS) === -1,
isEnabled: title => !!title && title.closable && !title.className.includes(PINNED_CLASS),
execute: title => this.togglePinned(title),
}));
commandRegistry.registerCommand(CommonCommands.UNPIN_TAB, new CurrentWidgetCommandAdapter(this.shell, {
isEnabled: title => !!title && title.className.indexOf(PINNED_CLASS) >= 0,
isEnabled: title => !!title && !title.closable && title.className.includes(PINNED_CLASS),
execute: title => this.togglePinned(title),
}));
commandRegistry.registerCommand(CommonCommands.CONFIGURE_DISPLAY_LANGUAGE, {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/browser/shell/tab-bars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { IconThemeService } from '../icon-theme-service';
import { BreadcrumbsRenderer, BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer';
import { NavigatableWidget } from '../navigatable-types';
import { IDragEvent } from '@phosphor/dragdrop';
import { PINNED_CLASS } from '../widgets/widget';

/** The class name added to hidden content nodes, which are required to render vertical side bars. */
const HIDDEN_CONTENT_CLASS = 'theia-TabBar-hidden-content';
Expand Down Expand Up @@ -475,7 +476,7 @@ export class TabBarRenderer extends TabBar.Renderer {
if (this.tabBar && event.currentTarget instanceof HTMLElement) {
const id = event.currentTarget.parentElement!.id;
const title = this.tabBar.titles.find(t => this.createTabId(t) === id);
if (title && title.className.indexOf('theia-mod-pinned') >= 0 && this.commandService) {
if (title?.closable === false && title?.className.includes(PINNED_CLASS) && this.commandService) {
this.commandService.executeCommand('workbench.action.unpinEditor', event);
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/browser/view-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { interfaces, injectable, inject, postConstruct } from 'inversify';
import { IIterator, toArray, find, some, every, map, ArrayExt } from '@phosphor/algorithm';
import {
Widget, EXPANSION_TOGGLE_CLASS, COLLAPSED_CLASS, CODICON_TREE_ITEM_CLASSES, MessageLoop, Message, SplitPanel,
BaseWidget, addEventListener, SplitLayout, LayoutItem, PanelLayout, addKeyListener, waitForRevealed, UnsafeWidgetUtilities, DockPanel
BaseWidget, addEventListener, SplitLayout, LayoutItem, PanelLayout, addKeyListener, waitForRevealed, UnsafeWidgetUtilities, DockPanel, PINNED_CLASS
} from './widgets';
import { Event as CommonEvent, Emitter } from '../common/event';
import { Disposable, DisposableCollection } from '../common/disposable';
Expand Down Expand Up @@ -276,7 +276,9 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica
if (title.iconClass) {
this.title.iconClass = title.iconClass;
}
if (title.closeable !== undefined) {
if (this.title.className.includes(PINNED_CLASS)) {
this.title.closable &&= false;
} else if (title.closeable !== undefined) {
this.title.closable = title.closeable;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/widgets/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const BUSY_CLASS = 'theia-mod-busy';
export const CODICON_LOADING_CLASSES = codiconArray('loading');
export const SELECTED_CLASS = 'theia-mod-selected';
export const FOCUS_CLASS = 'theia-mod-focus';
export const PINNED_CLASS = 'theia-mod-pinned';
export const DEFAULT_SCROLL_OPTIONS: PerfectScrollbar.Options = {
suppressScrollX: true,
minScrollbarLength: 35,
Expand Down

0 comments on commit f39b1f7

Please sign in to comment.