Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat - relayout when input toolbar changes #195877

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
private inputEditorHasText: IContextKey<boolean>;
private providerId: string | undefined;

private cachedDimensions: dom.Dimension | undefined;
private cachedToolbarWidth: number | undefined;

readonly inputUri = URI.parse(`${ChatInputPart.INPUT_SCHEME}:input-${ChatInputPart._counter++}`);

constructor(
Expand Down Expand Up @@ -251,6 +254,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}));
this.toolbar.getElement().classList.add('interactive-execute-toolbar');
this.toolbar.context = <IChatExecuteActionContext>{ widget };
this._register(this.toolbar.onDidChangeMenuItems(() => {
if (this.cachedDimensions && typeof this.cachedToolbarWidth === 'number' && this.cachedToolbarWidth !== this.toolbar.getItemsWidth()) {
this.layout(this.cachedDimensions.height, this.cachedDimensions.width);
}
}));

if (this.options.renderStyle === 'compact') {
const toolbarSide = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, inputAndSideToolbar, MenuId.ChatInputSide, {
Expand Down Expand Up @@ -285,6 +293,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}

layout(height: number, width: number): number {
this.cachedDimensions = new dom.Dimension(width, height);

return this._layout(height, width);
}

Expand All @@ -301,7 +311,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge

const editorBorder = 2;
const editorPadding = 8;
const executeToolbarWidth = this.toolbar.getItemsWidth();
const executeToolbarWidth = this.cachedToolbarWidth = this.toolbar.getItemsWidth();
const sideToolbarWidth = this.options.renderStyle === 'compact' ? 20 : 0;

const initialEditorScrollWidth = this._inputEditor.getScrollWidth();
Expand Down