Skip to content

Commit

Permalink
Add preferences wraptabs
Browse files Browse the repository at this point in the history
Add `wraptabs` preferences at setting menu, and modify the coresponding css styles to make whole display fit the wrapped tabs.
  • Loading branch information
smart-bo committed Dec 7, 2021
1 parent c4c6cab commit df53c4c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
this.registerCtrlWHandling();

this.updateStyles();
this.wrapTabs();
this.updateThemeFromPreference('workbench.colorTheme');
this.updateThemeFromPreference('workbench.iconTheme');
this.preferences.onPreferenceChanged(e => this.handlePreferenceChange(e, app));
Expand Down Expand Up @@ -407,6 +408,13 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
}
}

protected wrapTabs(): void {
document.body.classList.remove('theia-editor-wrapTabs');
if (this.preferences['workbench.editor.wraptabs']) {
document.body.classList.add('theia-editor-wrapTabs');
}
}

protected updateThemePreference(preferenceName: 'workbench.colorTheme' | 'workbench.iconTheme'): void {
const inspect = this.preferenceService.inspect<string | null>(preferenceName);
const workspaceValue = inspect && inspect.workspaceValue;
Expand Down Expand Up @@ -460,6 +468,10 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
}
break;
}
case 'workbench.editor.wraptabs': {
this.wrapTabs();
break;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/browser/core-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export const corePreferenceSchema: PreferenceSchema = {
'description': nls.localizeByDefault('Controls whether a top border is drawn on modified (dirty) editor tabs or not. This value is ignored when `#workbench.editor.showTabs#` is disabled.'),
'default': false
},
'workbench.editor.wraptabs': {
'type': 'boolean',
// eslint-disable-next-line max-len
'description': nls.localizeByDefault('Controls whether tabs should be wrapped over multiple lines when exceeding available space or whether a scrollbar should appear instead.'),
'default': false
},
'workbench.editor.closeOnFileDelete': {
'type': 'boolean',
// eslint-disable-next-line max-len
Expand Down Expand Up @@ -148,6 +154,7 @@ export interface CoreConfiguration {
'workbench.list.openMode': 'singleClick' | 'doubleClick';
'workbench.commandPalette.history': number;
'workbench.editor.highlightModifiedTabs': boolean;
'workbench.editor.wraptabs': boolean;
'workbench.editor.closeOnFileDelete': boolean;
'workbench.colorTheme': string;
'workbench.iconTheme': string | null;
Expand Down
31 changes: 31 additions & 0 deletions packages/core/src/browser/style/tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,34 @@ body.theia-editor-highlightModifiedTabs
flex-flow: row nowrap;
min-width: 100%;
}

/* When wraptabs is selected*/
body.theia-editor-wrapTabs
.p-TabBar .p-TabBar-content {
cursor: pointer;
display: flex;
flex-flow: row wrap;
}

body.theia-editor-wrapTabs
#theia-main-content-panel .p-Widget.p-DockPanel-widget {
background: var(--theia-editor-background);
position: relative !important;
top:0px !important;
}

body.theia-editor-wrapTabs
.p-TabBar.theia-tabBar-multirow[data-orientation='horizontal'] {
min-height: calc(var(--theia-breadcrumbs-height) + var(--theia-horizontal-toolbar-height));
flex-direction: column;
position: static !important;
height: fit-content !important;
}

body.theia-editor-wrapTabs
.p-TabBar.theia-app-centers {
background: var(--theia-editorGroupHeader-tabsBackground);
position: static !important;
height: fit-content !important;
}

0 comments on commit df53c4c

Please sign in to comment.