Skip to content

Commit

Permalink
fix window title issue (microsoft#242252)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge authored Feb 27, 2025
1 parent 68d736a commit a7b227e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { IQuickInputService } from '../../../../platform/quickinput/common/quick
import { WindowTitle } from './windowTitle.js';
import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js';
import { IHoverService } from '../../../../platform/hover/browser/hover.js';
import { IAccessibilityService } from '../../../../platform/accessibility/common/accessibility.js';

export class CommandCenterControl {

Expand Down Expand Up @@ -87,7 +86,6 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
@IKeybindingService private _keybindingService: IKeybindingService,
@IInstantiationService private _instaService: IInstantiationService,
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
) {
super(undefined, _submenu.actions.find(action => action.id === 'workbench.action.quickOpenWithModes') ?? _submenu.actions[0], options);
this._hoverDelegate = options.hoverDelegate ?? getDefaultHoverDelegate('mouse');
Expand Down Expand Up @@ -167,9 +165,6 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
labelElement.innerText = this._getLabel();
}));

this._store.add(that._accessibilityService.onDidChangeScreenReaderOptimized(() => labelElement.innerText = this._getLabel(true)));


// update label & tooltip when tabs visibility changes
this._store.add(that._editorGroupService.onDidChangeEditorPartOptions(({ newPartOptions, oldPartOptions }) => {
if (newPartOptions.showTabs !== oldPartOptions.showTabs) {
Expand All @@ -183,10 +178,10 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
return that.getTooltip();
}

private _getLabel(screenReaderModeChanged?: boolean): string {
private _getLabel(): string {
const { prefix, suffix } = that._windowTitle.getTitleDecorations();
let label = that._windowTitle.workspaceName;
if (screenReaderModeChanged || that._windowTitle.isCustomTitleFormat()) {
if (that._windowTitle.isCustomTitleFormat()) {
label = that._windowTitle.getWindowTitle();
} else if (that._editorGroupService.partOptions.showTabs === 'none') {
label = that._windowTitle.fileName ?? label;
Expand Down
10 changes: 4 additions & 6 deletions src/vs/workbench/browser/parts/titlebar/windowTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ export class WindowTitle extends Disposable {
this.titleUpdater.schedule();
}
}));
this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => {
if (this.accessibilityService.isScreenReaderOptimized() && !this.titleIncludesEditorState
|| !this.accessibilityService.isScreenReaderOptimized() && this.titleIncludesEditorState) {
this.titleUpdater.schedule();
}
}));
this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => this.titleUpdater.schedule()));
}

private onConfigurationChanged(event: IConfigurationChangeEvent): void {
Expand Down Expand Up @@ -413,6 +408,9 @@ export class WindowTitle extends Disposable {
}

isCustomTitleFormat(): boolean {
if (this.accessibilityService.isScreenReaderOptimized() || this.titleIncludesEditorState) {
return true;
}
const title = this.configurationService.inspect<string>(WindowSettingNames.title);
const titleSeparator = this.configurationService.inspect<string>(WindowSettingNames.titleSeparator);

Expand Down

0 comments on commit a7b227e

Please sign in to comment.