Skip to content

Commit

Permalink
Merge pull request #456 from che-incubator/banner-message
Browse files Browse the repository at this point in the history
feat: Add a setting that allows to control window header text separately from a window title
  • Loading branch information
RomanNikitenko authored Dec 6, 2024
2 parents 96b74da + 7f6259f commit 75377ec
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .rebase/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

The file to keep a list of changed files which will potentionaly help to resolve rebase conflicts.

#### @RomanNikitenko
https://github.com/che-incubator/che-code/pull/456

- code/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts
- code/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
- code/src/vs/workbench/browser/parts/titlebar/windowTitle.ts
- code/src/vs/workbench/browser/workbench.contribution.ts
---

#### @benoitf @RomanNikitenko
https://github.com/che-incubator/che-code/pull/379 \
https://github.com/che-incubator/che-code/commit/d3cf7dc86d284bc4cdff7cc163c5642bb6744524#diff-36f85da944a1b6c01cb656687e520f7415d692e1b7d8856e2161db97a134b224
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"from": "if (that._windowTitle.isCustomTitleFormat()) {",
"by": "const header = that._windowTitle.getHeader();\\\n\\\t\\\t\\\t\\\t\\\t\\\t\\\tif (header) {\\\n\\\t\\\t\\\t\\\t\\\t\\\t\\\t\\\tlabel = header;\\\n\\\t\\\t\\\t\\\t\\\t\\\t\\\t} else if (that._windowTitle.isCustomTitleFormat()) {"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"from": "this.title.innerText = this.windowTitle.value;",
"by": "this.title.innerText = this.windowTitle.getHeader() \\|\\| this.windowTitle.value;"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"from": "title = 'window.title'",
"by": "title = 'window.title',\\\n\\\theader = 'window.header'"
},
{
"from": "isCustomTitleFormat(): boolean {",
"by": "getHeader(): string \\| undefined{\\\n\\\t\\\tconst header = this.configurationService.inspect<string>(WindowSettingNames.header);\\\n\\\t\\\treturn header.value;\\\n\\\t}\\\n\\\n\\\tisCustomTitleFormat(): boolean {"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"from": "\\/\\/ Window",
"by": "\\/\\/ Window\\\n\\\tconst windowHeaderDescription = 'Controls the window header';"
},
{
"from": "'window.title': {",
"by": "'window.header': {\\\n\\\t\\\t\\\t\\\t'type': 'string',\\\n\\\t\\\t\\\t\\\t'markdownDescription': windowHeaderDescription\\\n\\\t\\\t\\\t},\\\n\\\t\\\t\\\t'window.title': {"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
private _getLabel(): string {
const { prefix, suffix } = that._windowTitle.getTitleDecorations();
let label = that._windowTitle.workspaceName;
if (that._windowTitle.isCustomTitleFormat()) {
const header = that._windowTitle.getHeader();
if (header) {
label = header;
} else if (that._windowTitle.isCustomTitleFormat()) {
label = that._windowTitle.getWindowTitle();
} else if (that._editorGroupService.partOptions.showTabs === 'none') {
label = that._windowTitle.fileName ?? label;
Expand Down
4 changes: 2 additions & 2 deletions code/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {

// Text Title
if (!this.isCommandCenterVisible) {
this.title.innerText = this.windowTitle.value;
this.title.innerText = this.windowTitle.getHeader() || this.windowTitle.value;
this.titleDisposables.add(this.windowTitle.onDidChange(() => {
this.title.innerText = this.windowTitle.value;
this.title.innerText = this.windowTitle.getHeader() || this.windowTitle.value;
}));
}

Expand Down
8 changes: 7 additions & 1 deletion code/src/vs/workbench/browser/parts/titlebar/windowTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import { CodeWindow } from '../../../../base/browser/window.js';

const enum WindowSettingNames {
titleSeparator = 'window.titleSeparator',
title = 'window.title'
title = 'window.title',
header = 'window.header'
}

export const defaultWindowTitle = (() => {
Expand Down Expand Up @@ -382,6 +383,11 @@ export class WindowTitle extends Disposable {
});
}

getHeader(): string | undefined{
const header = this.configurationService.inspect<string>(WindowSettingNames.header);
return header.value;
}

isCustomTitleFormat(): boolean {
const title = this.configurationService.inspect<string>(WindowSettingNames.title);
const titleSeparator = this.configurationService.inspect<string>(WindowSettingNames.titleSeparator);
Expand Down
6 changes: 5 additions & 1 deletion code/src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
});

// Window

const windowHeaderDescription = 'Controls the window header';
let windowTitleDescription = localize('windowTitle', "Controls the window title based on the current context such as the opened workspace or active editor. Variables are substituted based on the context:");
windowTitleDescription += '\n- ' + [
localize('activeEditorShort', "`${activeEditorShort}`: the file name (e.g. myFile.txt)."),
Expand All @@ -664,6 +664,10 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
registry.registerConfiguration({
...windowConfigurationNodeBase,
'properties': {
'window.header': {
'type': 'string',
'markdownDescription': windowHeaderDescription
},
'window.title': {
'type': 'string',
'default': defaultWindowTitle,
Expand Down
8 changes: 8 additions & 0 deletions rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ resolve_conflicts() {
apply_changes "$conflictingFile"
elif [[ "$conflictingFile" == "code/src/vs/code/browser/workbench/workbench.html" ]]; then
apply_changes "$conflictingFile"
elif [[ "$conflictingFile" == "code/src/vs/workbench/browser/workbench.contribution.ts" ]]; then
apply_changes "$conflictingFile"
elif [[ "$conflictingFile" == "code/src/vs/workbench/browser/parts/titlebar/windowTitle.ts" ]]; then
apply_changes "$conflictingFile"
elif [[ "$conflictingFile" == "code/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts" ]]; then
apply_changes "$conflictingFile"
elif [[ "$conflictingFile" == "code/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts" ]]; then
apply_changes "$conflictingFile"
else
echo "$conflictingFile file cannot be automatically rebased. Aborting"
exit 1
Expand Down

0 comments on commit 75377ec

Please sign in to comment.