@@ -134,6 +134,7 @@ class QuickChat extends Disposable {
134
134
private model : ChatModel | undefined ;
135
135
private _currentQuery : string | undefined ;
136
136
private maintainScrollTimer : MutableDisposable < IDisposable > = this . _register ( new MutableDisposable < IDisposable > ( ) ) ;
137
+ private _deferUpdatingDynamicLayout : boolean = false ;
137
138
138
139
constructor (
139
140
private readonly _options : IChatViewOptions ,
@@ -183,6 +184,10 @@ class QuickChat extends Disposable {
183
184
this . widget . setVisible ( true ) ;
184
185
// If the mutable disposable is set, then we are keeping the existing scroll position
185
186
// so we should not update the layout.
187
+ if ( this . _deferUpdatingDynamicLayout ) {
188
+ this . _deferUpdatingDynamicLayout = false ;
189
+ this . widget . updateDynamicChatTreeItemLayout ( 2 , this . maxHeight ) ;
190
+ }
186
191
if ( ! this . maintainScrollTimer . value ) {
187
192
this . widget . layoutDynamicChatTreeItemMode ( ) ;
188
193
}
@@ -222,7 +227,14 @@ class QuickChat extends Disposable {
222
227
223
228
private registerListeners ( parent : HTMLElement ) : void {
224
229
this . _register ( this . layoutService . onDidLayout ( ( ) => {
225
- this . widget . updateDynamicChatTreeItemLayout ( 2 , this . maxHeight ) ;
230
+ if ( this . widget . visible ) {
231
+ this . widget . updateDynamicChatTreeItemLayout ( 2 , this . maxHeight ) ;
232
+ } else {
233
+ // If the chat is not visible, then we should defer updating the layout
234
+ // because it relies on offsetHeight which only works correctly
235
+ // when the chat is visible.
236
+ this . _deferUpdatingDynamicLayout = true ;
237
+ }
226
238
} ) ) ;
227
239
this . _register ( this . widget . inputEditor . onDidChangeModelContent ( ( e ) => {
228
240
this . _currentQuery = this . widget . inputEditor . getValue ( ) ;
0 commit comments