@@ -31,7 +31,7 @@ import { memoize } from 'vs/base/common/decorators';
3131import { dispose , IDisposable } from 'vs/base/common/lifecycle' ;
3232import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
3333import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget' ;
34- import { IDebugService , REPL_ID , DEBUG_SCHEME , CONTEXT_IN_DEBUG_REPL , IDebugSession , State , IReplElement , IExpressionContainer , IExpression , IReplElementSource } from 'vs/workbench/contrib/debug/common/debug' ;
34+ import { IDebugService , REPL_ID , DEBUG_SCHEME , CONTEXT_IN_DEBUG_REPL , IDebugSession , State , IReplElement , IExpressionContainer , IExpression , IReplElementSource , IDebugConfiguration } from 'vs/workbench/contrib/debug/common/debug' ;
3535import { HistoryNavigator } from 'vs/base/common/history' ;
3636import { IHistoryNavigationWidget } from 'vs/base/browser/history' ;
3737import { createAndBindHistoryNavigationWidgetScopedContextKeyService } from 'vs/platform/browser/contextScopedHistoryWidget' ;
@@ -97,7 +97,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
9797 private tree : WorkbenchAsyncDataTree < IDebugSession , IReplElement , FuzzyScore > ;
9898 private replDelegate : ReplDelegate ;
9999 private container : HTMLElement ;
100- private treeContainer : HTMLElement ;
101100 private replInput : CodeEditorWidget ;
102101 private replInputContainer : HTMLElement ;
103102 private dimension : dom . Dimension ;
@@ -106,6 +105,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
106105 private historyNavigationEnablement : IContextKey < boolean > ;
107106 private scopedInstantiationService : IInstantiationService ;
108107 private replElementsChangeListener : IDisposable ;
108+ private styleElement : HTMLStyleElement ;
109109
110110 constructor (
111111 @IDebugService private readonly debugService : IDebugService ,
@@ -158,6 +158,11 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
158158 this . refreshReplElements ( true ) ;
159159 }
160160 } ) ) ;
161+ this . _register ( this . configurationService . onDidChangeConfiguration ( e => {
162+ if ( e . affectsConfiguration ( 'debug.console.lineHeight' ) || e . affectsConfiguration ( 'debug.console.fontSize' ) || e . affectsConfiguration ( 'debug.console.fontFamily' ) ) {
163+ this . onDidFontChange ( ) ;
164+ }
165+ } ) ) ;
161166 }
162167
163168 get isReadonly ( ) : boolean {
@@ -178,6 +183,33 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
178183 this . navigateHistory ( false ) ;
179184 }
180185
186+ private onDidFontChange ( ) : void {
187+ if ( this . styleElement ) {
188+ const debugConsole = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) . console ;
189+ const fontSize = debugConsole . fontSize ;
190+ const fontFamily = debugConsole . fontFamily === 'default' ? 'var(--monaco-monospace-font)' : debugConsole . fontFamily ;
191+ const lineHeight = debugConsole . lineHeight ? `${ debugConsole . lineHeight } px` : '1.4em' ;
192+
193+ // Set the font size, font family, line height and align the twistie to be centered
194+ this . styleElement . innerHTML = `
195+ .repl .repl-tree .expression {
196+ font-size: ${ fontSize } px;
197+ font-family: ${ fontFamily } ;
198+ }
199+
200+ .repl .repl-tree .expression {
201+ line-height: ${ lineHeight } ;
202+ }
203+
204+ .repl .repl-tree .monaco-tl-twistie {
205+ background-position-y: calc(100% - ${ fontSize * 1.4 / 2 - 8 } px);
206+ }
207+ ` ;
208+
209+ this . tree . rerender ( ) ;
210+ }
211+ }
212+
181213 private navigateHistory ( previous : boolean ) : void {
182214 const historyInput = previous ? this . history . previous ( ) : this . history . next ( ) ;
183215 if ( historyInput ) {
@@ -266,7 +298,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
266298 this . dimension = dimension ;
267299 if ( this . tree ) {
268300 const treeHeight = dimension . height - this . replInputHeight ;
269- this . treeContainer . style . height = `${ treeHeight } px` ;
301+ this . tree . getHTMLElement ( ) . style . height = `${ treeHeight } px` ;
270302 this . tree . layout ( treeHeight , dimension . width ) ;
271303 }
272304 this . replInputContainer . style . height = `${ this . replInputHeight } px` ;
@@ -330,11 +362,11 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
330362 create ( parent : HTMLElement ) : void {
331363 super . create ( parent ) ;
332364 this . container = dom . append ( parent , $ ( '.repl' ) ) ;
333- this . treeContainer = dom . append ( this . container , $ ( '.repl-tree' ) ) ;
365+ const treeContainer = dom . append ( this . container , $ ( '.repl-tree' ) ) ;
334366 this . createReplInput ( this . container ) ;
335367
336- this . replDelegate = new ReplDelegate ( ) ;
337- this . tree = new WorkbenchAsyncDataTree ( this . treeContainer , this . replDelegate , [
368+ this . replDelegate = new ReplDelegate ( this . configurationService ) ;
369+ this . tree = new WorkbenchAsyncDataTree ( treeContainer , this . replDelegate , [
338370 this . instantiationService . createInstance ( VariablesRenderer ) ,
339371 this . instantiationService . createInstance ( ReplSimpleElementsRenderer ) ,
340372 new ReplExpressionsRenderer ( ) ,
@@ -346,12 +378,15 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
346378 mouseSupport : false ,
347379 keyboardNavigationLabelProvider : { getKeyboardNavigationLabel : e => e } ,
348380 horizontalScrolling : false ,
381+ setRowLineHeight : false ,
349382 supportDynamicHeights : true
350383 } , this . contextKeyService , this . listService , this . themeService , this . configurationService , this . keybindingService ) ;
351384
352385 this . toDispose . push ( this . tree . onContextMenu ( e => this . onContextMenu ( e ) ) ) ;
353386 // Make sure to select the session if debugging is already active
354387 this . selectSession ( ) ;
388+ this . styleElement = dom . createStyleSheet ( this . container ) ;
389+ this . onDidFontChange ( ) ;
355390 }
356391
357392 private createReplInput ( container : HTMLElement ) : void {
@@ -666,14 +701,16 @@ class ReplRawObjectsRenderer implements ITreeRenderer<RawObjectReplElement, Fuzz
666701
667702class ReplDelegate implements IListVirtualDelegate < IReplElement > {
668703
669- private static readonly LINE_HEIGHT_PX = 18 ;
704+ constructor ( private configurationService : IConfigurationService ) { }
670705
671706 getHeight ( element : IReplElement ) : number {
707+ // Give approximate heights. Repl has dynamic height so the tree will measure the actual height on its own.
708+ const fontSize = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) . console . fontSize ;
672709 if ( element instanceof Expression && element . hasChildren ) {
673- return 2 * ReplDelegate . LINE_HEIGHT_PX ;
710+ return Math . ceil ( 2 * 1.4 * fontSize ) ;
674711 }
675712
676- return ReplDelegate . LINE_HEIGHT_PX ;
713+ return Math . ceil ( 1.4 * fontSize ) ;
677714 }
678715
679716 getTemplateId ( element : IReplElement ) : string {
0 commit comments