未验证 提交 ef4df46f 编写于 作者: B Benjamin Pasero 提交者: GitHub

Allow to shrink tabs instead of keeping a minimum width (fixes #15048) (#39176)

上级 6d22bb75
...@@ -227,6 +227,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro ...@@ -227,6 +227,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
private updateTabOptions(tabOptions: IEditorTabOptions, refresh?: boolean): void { private updateTabOptions(tabOptions: IEditorTabOptions, refresh?: boolean): void {
const tabCloseButton = this.tabOptions ? this.tabOptions.tabCloseButton : 'right'; const tabCloseButton = this.tabOptions ? this.tabOptions.tabCloseButton : 'right';
const tabSizing = this.tabOptions ? this.tabOptions.tabSizing : 'fit';
this.tabOptions = tabOptions; this.tabOptions = tabOptions;
if (!refresh) { if (!refresh) {
...@@ -263,8 +265,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro ...@@ -263,8 +265,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
this.createTitleControl(this.stacks.groupAt(position), this.silos[position], titleContainer, this.getInstantiationService(position)); this.createTitleControl(this.stacks.groupAt(position), this.silos[position], titleContainer, this.getInstantiationService(position));
} }
// Refresh title when icons change // Refresh title when layout options change
else if (showingIcons !== this.tabOptions.showIcons || tabCloseButton !== this.tabOptions.tabCloseButton) { else if (showingIcons !== this.tabOptions.showIcons || tabCloseButton !== this.tabOptions.tabCloseButton || tabSizing !== this.tabOptions.tabSizing) {
titleControl.refresh(); titleControl.refresh();
} }
} }
......
...@@ -162,6 +162,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -162,6 +162,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
showIcons: editorConfig.showIcons, showIcons: editorConfig.showIcons,
showTabs: editorConfig.showTabs, showTabs: editorConfig.showTabs,
tabCloseButton: editorConfig.tabCloseButton, tabCloseButton: editorConfig.tabCloseButton,
tabSizing: editorConfig.tabSizing,
labelFormat: editorConfig.labelFormat, labelFormat: editorConfig.labelFormat,
}; };
...@@ -172,6 +173,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -172,6 +173,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
showIcons: false, showIcons: false,
showTabs: true, showTabs: true,
tabCloseButton: 'right', tabCloseButton: 'right',
tabSizing: 'fit',
labelFormat: 'default', labelFormat: 'default',
}; };
...@@ -225,6 +227,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -225,6 +227,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
previewEditors: newPreviewEditors, previewEditors: newPreviewEditors,
showIcons: editorConfig.showIcons, showIcons: editorConfig.showIcons,
tabCloseButton: editorConfig.tabCloseButton, tabCloseButton: editorConfig.tabCloseButton,
tabSizing: editorConfig.tabSizing,
showTabs: this.forceHideTabs ? false : editorConfig.showTabs, showTabs: this.forceHideTabs ? false : editorConfig.showTabs,
labelFormat: editorConfig.labelFormat, labelFormat: editorConfig.labelFormat,
}; };
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab { .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab {
display: flex; display: flex;
width: 120px;
min-width: fit-content;
white-space: nowrap; white-space: nowrap;
cursor: pointer; cursor: pointer;
height: 35px; height: 35px;
...@@ -47,6 +45,22 @@ ...@@ -47,6 +45,22 @@
padding-left: 10px; padding-left: 10px;
} }
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-fit {
width: 120px;
min-width: fit-content;
}
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-shrink {
min-width: 80px;
flex-basis: 0; /* all tabs are even */
flex-grow: 1; /* all tabs grow even */
max-width: fit-content;
}
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-shrink.tab.close-button-off {
min-width: 60px;
}
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dragged { .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.dragged {
will-change: transform; /* forces tab to be drawn on a separate layer (fixes https://github.com/Microsoft/vscode/issues/18733) */ will-change: transform; /* forces tab to be drawn on a separate layer (fixes https://github.com/Microsoft/vscode/issues/18733) */
} }
...@@ -68,8 +82,8 @@ ...@@ -68,8 +82,8 @@
margin-bottom: auto; margin-bottom: auto;
} }
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab .monaco-icon-label, .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-fit .monaco-icon-label,
.monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab .monaco-icon-label > .monaco-icon-label-description-container { .monaco-workbench > .part.editor > .content > .one-editor-silo > .container > .title .tabs-container > .tab.sizing-fit .monaco-icon-label > .monaco-icon-label-description-container {
overflow: visible; /* fixes https://github.com/Microsoft/vscode/issues/20182 */ overflow: visible; /* fixes https://github.com/Microsoft/vscode/issues/20182 */
} }
......
...@@ -307,11 +307,17 @@ export class TabsTitleControl extends TitleControl { ...@@ -307,11 +307,17 @@ export class TabsTitleControl extends TitleControl {
tabContainer.style.outlineColor = this.getColor(activeContrastBorder); tabContainer.style.outlineColor = this.getColor(activeContrastBorder);
const tabOptions = this.editorGroupService.getTabOptions(); const tabOptions = this.editorGroupService.getTabOptions();
['off', 'left'].forEach(option => { ['off', 'left'].forEach(option => {
const domAction = tabOptions.tabCloseButton === option ? DOM.addClass : DOM.removeClass; const domAction = tabOptions.tabCloseButton === option ? DOM.addClass : DOM.removeClass;
domAction(tabContainer, `close-button-${option}`); domAction(tabContainer, `close-button-${option}`);
}); });
['fit', 'shrink'].forEach(option => {
const domAction = tabOptions.tabSizing === option ? DOM.addClass : DOM.removeClass;
domAction(tabContainer, `sizing-${option}`);
});
// Label // Label
const tabLabel = this.editorLabels[index]; const tabLabel = this.editorLabels[index];
tabLabel.setLabel({ name, description, resource: toResource(editor, { supportSideBySide: true }) }, { extraClasses: ['tab-label'], italic: !isPinned }); tabLabel.setLabel({ name, description, resource: toResource(editor, { supportSideBySide: true }) }, { extraClasses: ['tab-label'], italic: !isPinned });
......
...@@ -808,23 +808,11 @@ export const EditorOpenPositioning = { ...@@ -808,23 +808,11 @@ export const EditorOpenPositioning = {
export const OPEN_POSITIONING_CONFIG = 'workbench.editor.openPositioning'; export const OPEN_POSITIONING_CONFIG = 'workbench.editor.openPositioning';
export interface IWorkbenchEditorConfiguration { export interface IWorkbenchEditorConfiguration {
/* __GDPR__FRAGMENT__
"IWorkbenchEditorConfiguration" : {
"showTabs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"tabCloseButton": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"showIcons": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"enablePreview": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"enablePreviewFromQuickOpen": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"closeOnFileDelete": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"openPositioning": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"revealIfOpen": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"swipeToNavigate": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
workbench: { workbench: {
editor: { editor: {
showTabs: boolean; showTabs: boolean;
tabCloseButton: 'left' | 'right' | 'off'; tabCloseButton: 'left' | 'right' | 'off';
tabSizing: 'fit' | 'shrink';
showIcons: boolean; showIcons: boolean;
enablePreview: boolean; enablePreview: boolean;
enablePreviewFromQuickOpen: boolean; enablePreviewFromQuickOpen: boolean;
......
...@@ -157,6 +157,12 @@ let workbenchProperties: { [path: string]: IJSONSchema; } = { ...@@ -157,6 +157,12 @@ let workbenchProperties: { [path: string]: IJSONSchema; } = {
'default': 'right', 'default': 'right',
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'editorTabCloseButton' }, "Controls the position of the editor's tabs close buttons or disables them when set to 'off'.") 'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'editorTabCloseButton' }, "Controls the position of the editor's tabs close buttons or disables them when set to 'off'.")
}, },
'workbench.editor.tabSizing': {
'type': 'string',
'enum': ['fit', 'shrink'],
'default': 'fit',
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'tabSizing' }, "Controls the sizing of editor tabs. Set to 'fit' to keep tabs always large enough to show the full editor label. Set to 'shrink' to allow tabs to get smaller when the available space is not enough to show all tabs at once.")
},
'workbench.editor.showIcons': { 'workbench.editor.showIcons': {
'type': 'boolean', 'type': 'boolean',
'description': nls.localize('showIcons', "Controls if opened editors should show with an icon or not. This requires an icon theme to be enabled as well."), 'description': nls.localize('showIcons', "Controls if opened editors should show with an icon or not. This requires an icon theme to be enabled as well."),
......
...@@ -22,6 +22,7 @@ export const IEditorGroupService = createDecorator<IEditorGroupService>('editorG ...@@ -22,6 +22,7 @@ export const IEditorGroupService = createDecorator<IEditorGroupService>('editorG
export interface IEditorTabOptions { export interface IEditorTabOptions {
showTabs?: boolean; showTabs?: boolean;
tabCloseButton?: 'left' | 'right' | 'off'; tabCloseButton?: 'left' | 'right' | 'off';
tabSizing?: 'fit' | 'shrink';
showIcons?: boolean; showIcons?: boolean;
previewEditors?: boolean; previewEditors?: boolean;
labelFormat?: 'default' | 'short' | 'medium' | 'long'; labelFormat?: 'default' | 'short' | 'medium' | 'long';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册