Skip to content

Commit 1da74cc

Browse files
authored
Sessions - add a resize observer to the title to match the width of the chat part (#307877)
1 parent 8d41591 commit 1da74cc

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/vs/sessions/browser/parts/titlebarPart.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export class TitlebarPart extends Part implements ITitlebarPart {
8585
get rightContainer(): HTMLElement { return this.rightContent; }
8686
get rightWindowControlsContainer(): HTMLElement | undefined { return this.windowControlsContainer; }
8787

88+
private chatBarResizeObserver: ResizeObserver | undefined;
89+
8890
private readonly titleBarStyle: TitlebarStyle;
8991
private isInactive: boolean = false;
9092

@@ -282,6 +284,26 @@ export class TitlebarPart extends Part implements ITitlebarPart {
282284
override layout(width: number, height: number): void {
283285
this.updateLayout();
284286
super.layoutContents(width, height);
287+
this.installChatBarResizeObserver();
288+
}
289+
290+
private installChatBarResizeObserver(): void {
291+
if (this.chatBarResizeObserver) {
292+
return;
293+
}
294+
295+
const chatBarContainer = this.layoutService.getContainer(getWindow(this.element), Parts.CHATBAR_PART);
296+
if (!chatBarContainer) {
297+
return;
298+
}
299+
300+
this.chatBarResizeObserver = new ResizeObserver(entries => {
301+
for (const entry of entries) {
302+
this.centerContent.style.maxWidth = `${entry.contentRect.width}px`;
303+
}
304+
});
305+
this.chatBarResizeObserver.observe(chatBarContainer);
306+
this._register({ dispose: () => this.chatBarResizeObserver?.disconnect() });
285307
}
286308

287309
private updateLayout(): void {

0 commit comments

Comments
 (0)