File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/vs/workbench/contrib/debug/browser Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -312,18 +312,21 @@ export class ReplDelegate extends CachedListVirtualDelegate<IReplElement> {
312
312
return super . getHeight ( element ) ;
313
313
}
314
314
315
+ /**
316
+ * With wordWrap enabled, this is an estimate. With wordWrap disabled, this is the real height that the list will use.
317
+ */
315
318
protected estimateHeight ( element : IReplElement , ignoreValueLength = false ) : number {
316
319
const lineHeight = this . replOptions . replConfiguration . lineHeight ;
317
- const countNumberOfLines = ( str : string ) => Math . max ( 1 , ( str && str . match ( / \r \n | \n / g) || [ ] ) . length ) ;
320
+ const countNumberOfLines = ( str : string ) => str . match ( / \n / g) ? .length ?? 0 ;
318
321
const hasValue = ( e : any ) : e is { value : string } => typeof e . value === 'string' ;
319
322
320
- // Calculate a rough overestimation for the height
321
- // For every 70 characters increase the number of lines needed beyond the first
322
323
if ( hasValue ( element ) && ! isNestedVariable ( element ) ) {
323
324
const value = element . value ;
324
- const valueRows = countNumberOfLines ( value ) + ( ignoreValueLength ? 0 : Math . floor ( value . length / 70 ) ) ;
325
+ const valueRows = countNumberOfLines ( value )
326
+ + ( ignoreValueLength ? 0 : Math . floor ( value . length / 70 ) ) // Make an estimate for wrapping
327
+ + ( element instanceof SimpleReplElement ? 0 : 1 ) ; // A SimpleReplElement ends in \n if it's a complete line
325
328
326
- return valueRows * lineHeight ;
329
+ return Math . max ( valueRows , 1 ) * lineHeight ;
327
330
}
328
331
329
332
return lineHeight ;
You can’t perform that action at this time.
0 commit comments