提交 59c991e3 编写于 作者: B Benjamin Pasero

fix #107675

上级 db674322
......@@ -442,7 +442,7 @@ export class TabsTitleControl extends TitleControl {
}
pinEditor(editor: IEditorInput): void {
this.withTab(editor, (editor, index, tabContainer, tabLabelWidget, tabLabel) => this.redrawLabel(editor, index, tabContainer, tabLabelWidget, tabLabel));
this.withTab(editor, (editor, index, tabContainer, tabLabelWidget, tabLabel) => this.redrawTabLabel(editor, index, tabContainer, tabLabelWidget, tabLabel));
}
stickEditor(editor: IEditorInput): void {
......@@ -458,15 +458,21 @@ export class TabsTitleControl extends TitleControl {
// Update tab
this.withTab(editor, (editor, index, tabContainer, tabLabelWidget, tabLabel, tabActionBar) => this.redrawTab(editor, index, tabContainer, tabLabelWidget, tabLabel, tabActionBar));
// Sticky change has an impact on each tab's border because
// it potentially moves the border to the last pinned tab
this.forEachTab((editor, index, tabContainer, tabLabelWidget, tabLabel) => {
this.redrawTabBorders(index, tabContainer);
});
// A change to the sticky state requires a layout to keep the active editor visible
this.layout(this.dimension);
}
setActive(isGroupActive: boolean): void {
// Activity has an impact on each tab
// Activity has an impact on each tab's active indication
this.forEachTab((editor, index, tabContainer, tabLabelWidget, tabLabel) => {
this.redrawEditorActiveAndDirty(isGroupActive, editor, tabContainer, tabLabelWidget);
this.redrawTabActiveAndDirty(isGroupActive, editor, tabContainer, tabLabelWidget);
});
// Activity has an impact on the toolbar, so we need to update and layout
......@@ -493,7 +499,7 @@ export class TabsTitleControl extends TitleControl {
// As such we need to redraw each label
this.forEachTab((editor, index, tabContainer, tabLabelWidget, tabLabel) => {
this.redrawLabel(editor, index, tabContainer, tabLabelWidget, tabLabel);
this.redrawTabLabel(editor, index, tabContainer, tabLabelWidget, tabLabel);
});
// A change to a label requires a layout to keep the active editor visible
......@@ -501,7 +507,7 @@ export class TabsTitleControl extends TitleControl {
}
updateEditorDirty(editor: IEditorInput): void {
this.withTab(editor, (editor, index, tabContainer, tabLabelWidget) => this.redrawEditorActiveAndDirty(this.accessor.activeGroup === this.group, editor, tabContainer, tabLabelWidget));
this.withTab(editor, (editor, index, tabContainer, tabLabelWidget) => this.redrawTabActiveAndDirty(this.accessor.activeGroup === this.group, editor, tabContainer, tabLabelWidget));
}
updateOptions(oldOptions: IEditorPartOptions, newOptions: IEditorPartOptions): void {
......@@ -1020,11 +1026,10 @@ export class TabsTitleControl extends TitleControl {
private redrawTab(editor: IEditorInput, index: number, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel, tabLabel: IEditorInputLabel, tabActionBar: ActionBar): void {
const isTabSticky = this.group.isSticky(index);
const isTabLastSticky = isTabSticky && this.group.stickyCount === index + 1;
const options = this.accessor.partOptions;
// Label
this.redrawLabel(editor, index, tabContainer, tabLabelWidget, tabLabel);
this.redrawTabLabel(editor, index, tabContainer, tabLabelWidget, tabLabel);
// Action
const tabAction = isTabSticky ? this.unpinEditorAction : this.closeEditorAction;
......@@ -1035,11 +1040,6 @@ export class TabsTitleControl extends TitleControl {
tabActionBar.push(tabAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(tabAction) });
}
// Borders / Outline
const borderRightColor = ((isTabLastSticky ? this.getColor(TAB_LAST_PINNED_BORDER) : undefined) || this.getColor(TAB_BORDER) || this.getColor(contrastBorder));
tabContainer.style.borderRight = borderRightColor ? `1px solid ${borderRightColor}` : '';
tabContainer.style.outlineColor = this.getColor(activeContrastBorder) || '';
// Settings
const tabActionsVisibility = isTabSticky && options.pinnedTabSizing === 'compact' ? 'off' /* treat sticky compact tabs as tabCloseButton: 'off' */ : options.tabCloseButton;
['off', 'left', 'right'].forEach(option => {
......@@ -1079,11 +1079,14 @@ export class TabsTitleControl extends TitleControl {
tabContainer.style.left = 'auto';
}
// Borders / outline
this.redrawTabBorders(index, tabContainer);
// Active / dirty state
this.redrawEditorActiveAndDirty(this.accessor.activeGroup === this.group, editor, tabContainer, tabLabelWidget);
this.redrawTabActiveAndDirty(this.accessor.activeGroup === this.group, editor, tabContainer, tabLabelWidget);
}
private redrawLabel(editor: IEditorInput, index: number, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel, tabLabel: IEditorInputLabel): void {
private redrawTabLabel(editor: IEditorInput, index: number, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel, tabLabel: IEditorInputLabel): void {
const options = this.accessor.partOptions;
// Unless tabs are sticky compact, show the full label and description
......@@ -1127,15 +1130,15 @@ export class TabsTitleControl extends TitleControl {
}
}
private redrawEditorActiveAndDirty(isGroupActive: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void {
private redrawTabActiveAndDirty(isGroupActive: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void {
const isTabActive = this.group.isActive(editor);
const hasModifiedBorderTop = this.doRedrawEditorDirty(isGroupActive, isTabActive, editor, tabContainer);
const hasModifiedBorderTop = this.doRedrawTabDirty(isGroupActive, isTabActive, editor, tabContainer);
this.doRedrawEditorActive(isGroupActive, !hasModifiedBorderTop, editor, tabContainer, tabLabelWidget);
this.doRedrawTabActive(isGroupActive, !hasModifiedBorderTop, editor, tabContainer, tabLabelWidget);
}
private doRedrawEditorActive(isGroupActive: boolean, allowBorderTop: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void {
private doRedrawTabActive(isGroupActive: boolean, allowBorderTop: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void {
// Tab is active
if (this.group.isActive(editor)) {
......@@ -1181,7 +1184,7 @@ export class TabsTitleControl extends TitleControl {
}
}
private doRedrawEditorDirty(isGroupActive: boolean, isTabActive: boolean, editor: IEditorInput, tabContainer: HTMLElement): boolean {
private doRedrawTabDirty(isGroupActive: boolean, isTabActive: boolean, editor: IEditorInput, tabContainer: HTMLElement): boolean {
let hasModifiedBorderColor = false;
// Tab: dirty (unless saving)
......@@ -1222,6 +1225,16 @@ export class TabsTitleControl extends TitleControl {
return hasModifiedBorderColor;
}
private redrawTabBorders(index: number, tabContainer: HTMLElement): void {
const isTabSticky = this.group.isSticky(index);
const isTabLastSticky = isTabSticky && this.group.stickyCount === index + 1;
// Borders / Outline
const borderRightColor = ((isTabLastSticky ? this.getColor(TAB_LAST_PINNED_BORDER) : undefined) || this.getColor(TAB_BORDER) || this.getColor(contrastBorder));
tabContainer.style.borderRight = borderRightColor ? `1px solid ${borderRightColor}` : '';
tabContainer.style.outlineColor = this.getColor(activeContrastBorder) || '';
}
getDimensions(): IEditorGroupTitleDimensions {
let height = TabsTitleControl.TAB_HEIGHT;
if (this.breadcrumbsControl && !this.breadcrumbsControl.isHidden()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册