mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
add and use ChatInputPart#contentHeight (#209345)
fixes https://github.com/microsoft/vscode-copilot/issues/4727
This commit is contained in:
parent
1c26e87c0d
commit
dd0b11c533
|
@ -442,6 +442,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get contentHeight(): number {
|
||||||
|
const data = this.getLayoutData();
|
||||||
|
return data.followupsHeight + data.inputPartEditorHeight + data.inputPartVerticalPadding + data.inputEditorBorder + data.implicitContextHeight;
|
||||||
|
}
|
||||||
|
|
||||||
layout(height: number, width: number) {
|
layout(height: number, width: number) {
|
||||||
this.cachedDimensions = new dom.Dimension(width, height);
|
this.cachedDimensions = new dom.Dimension(width, height);
|
||||||
|
|
||||||
|
@ -450,25 +455,15 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
||||||
|
|
||||||
private previousInputEditorDimension: IDimension | undefined;
|
private previousInputEditorDimension: IDimension | undefined;
|
||||||
private _layout(height: number, width: number, allowRecurse = true): void {
|
private _layout(height: number, width: number, allowRecurse = true): void {
|
||||||
const followupsHeight = this.followupsContainer.offsetHeight;
|
|
||||||
|
|
||||||
const inputPartBorder = 0;
|
const data = this.getLayoutData();
|
||||||
const inputPartHorizontalPadding = this.options.renderStyle === 'compact' ? 8 : 40;
|
|
||||||
const inputPartVerticalPadding = this.options.renderStyle === 'compact' ? 12 : 24;
|
|
||||||
const inputEditorHeight = Math.min(this._inputEditor.getContentHeight(), height - followupsHeight - inputPartVerticalPadding - inputPartBorder, INPUT_EDITOR_MAX_HEIGHT);
|
|
||||||
const implicitContextHeight = this.implicitContextContainer.offsetHeight;
|
|
||||||
|
|
||||||
const inputEditorBorder = 2;
|
const inputEditorHeight = Math.min(data.inputPartEditorHeight, height - data.followupsHeight - data.inputPartVerticalPadding);
|
||||||
this._inputPartHeight = followupsHeight + inputEditorHeight + inputPartVerticalPadding + inputPartBorder + inputEditorBorder + implicitContextHeight;
|
|
||||||
|
|
||||||
const editorBorder = 2;
|
this._inputPartHeight = data.followupsHeight + inputEditorHeight + data.inputPartVerticalPadding + data.inputEditorBorder + data.implicitContextHeight;
|
||||||
const editorPadding = 12;
|
|
||||||
const executeToolbarWidth = this.cachedToolbarWidth = this.toolbar.getItemsWidth();
|
|
||||||
const toolbarPadding = 4;
|
|
||||||
const sideToolbarWidth = this.inputSideToolbarContainer ? dom.getTotalWidth(this.inputSideToolbarContainer) + 4 /*gap*/ : 0;
|
|
||||||
|
|
||||||
const initialEditorScrollWidth = this._inputEditor.getScrollWidth();
|
const initialEditorScrollWidth = this._inputEditor.getScrollWidth();
|
||||||
const newEditorWidth = width - inputPartHorizontalPadding - editorBorder - editorPadding - executeToolbarWidth - sideToolbarWidth - toolbarPadding;
|
const newEditorWidth = width - data.inputPartHorizontalPadding - data.editorBorder - data.editorPadding - data.executeToolbarWidth - data.sideToolbarWidth - data.toolbarPadding;
|
||||||
const newDimension = { width: newEditorWidth, height: inputEditorHeight };
|
const newDimension = { width: newEditorWidth, height: inputEditorHeight };
|
||||||
if (!this.previousInputEditorDimension || (this.previousInputEditorDimension.width !== newDimension.width || this.previousInputEditorDimension.height !== newDimension.height)) {
|
if (!this.previousInputEditorDimension || (this.previousInputEditorDimension.width !== newDimension.width || this.previousInputEditorDimension.height !== newDimension.height)) {
|
||||||
// This layout call has side-effects that are hard to understand. eg if we are calling this inside a onDidChangeContent handler, this can trigger the next onDidChangeContent handler
|
// This layout call has side-effects that are hard to understand. eg if we are calling this inside a onDidChangeContent handler, this can trigger the next onDidChangeContent handler
|
||||||
|
@ -483,6 +478,22 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getLayoutData() {
|
||||||
|
return {
|
||||||
|
inputEditorBorder: 2,
|
||||||
|
followupsHeight: this.followupsContainer.offsetHeight,
|
||||||
|
inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), INPUT_EDITOR_MAX_HEIGHT),
|
||||||
|
inputPartHorizontalPadding: this.options.renderStyle === 'compact' ? 8 : 40,
|
||||||
|
inputPartVerticalPadding: this.options.renderStyle === 'compact' ? 12 : 24,
|
||||||
|
implicitContextHeight: this.implicitContextContainer.offsetHeight,
|
||||||
|
editorBorder: 2,
|
||||||
|
editorPadding: 12,
|
||||||
|
toolbarPadding: 4,
|
||||||
|
executeToolbarWidth: this.cachedToolbarWidth = this.toolbar.getItemsWidth(),
|
||||||
|
sideToolbarWidth: this.inputSideToolbarContainer ? dom.getTotalWidth(this.inputSideToolbarContainer) + 4 /*gap*/ : 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
saveState(): void {
|
saveState(): void {
|
||||||
const inputHistory = this.history.getHistory();
|
const inputHistory = this.history.getHistory();
|
||||||
this.historyService.saveHistory(this.providerId!, inputHistory);
|
this.historyService.saveHistory(this.providerId!, inputHistory);
|
||||||
|
|
|
@ -258,7 +258,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
get contentHeight(): number {
|
get contentHeight(): number {
|
||||||
return dom.getTotalHeight(this.inputPart.element) + this.tree.contentHeight;
|
return this.inputPart.contentHeight + this.tree.contentHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
render(parent: HTMLElement): void {
|
render(parent: HTMLElement): void {
|
||||||
|
|
Loading…
Reference in a new issue