@@ -13,6 +13,7 @@ import { IAction } from 'vs/base/common/actions';
13
13
import { RunOnceScheduler } from 'vs/base/common/async' ;
14
14
import { CancellationToken } from 'vs/base/common/cancellation' ;
15
15
import { memoize } from 'vs/base/common/decorators' ;
16
+ import { Emitter } from 'vs/base/common/event' ;
16
17
import { FuzzyScore } from 'vs/base/common/filters' ;
17
18
import { HistoryNavigator } from 'vs/base/common/history' ;
18
19
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
@@ -62,7 +63,7 @@ import { debugConsoleClearAll, debugConsoleEvaluationPrompt } from 'vs/workbench
62
63
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector' ;
63
64
import { ReplFilter , ReplFilterActionViewItem , ReplFilterState } from 'vs/workbench/contrib/debug/browser/replFilter' ;
64
65
import { ReplAccessibilityProvider , ReplDataSource , ReplDelegate , ReplEvaluationInputsRenderer , ReplEvaluationResultsRenderer , ReplGroupRenderer , ReplRawObjectsRenderer , ReplSimpleElementsRenderer , ReplVariablesRenderer } from 'vs/workbench/contrib/debug/browser/replViewer' ;
65
- import { CONTEXT_DEBUG_STATE , CONTEXT_IN_DEBUG_REPL , CONTEXT_MULTI_SESSION_REPL , DEBUG_SCHEME , getStateLabel , IDebugConfiguration , IDebugService , IDebugSession , IReplElement , REPL_VIEW_ID , State } from 'vs/workbench/contrib/debug/common/debug' ;
66
+ import { CONTEXT_DEBUG_STATE , CONTEXT_IN_DEBUG_REPL , CONTEXT_MULTI_SESSION_REPL , DEBUG_SCHEME , getStateLabel , IDebugConfiguration , IDebugService , IDebugSession , IReplConfiguration , IReplElement , IReplOptions , REPL_VIEW_ID , State } from 'vs/workbench/contrib/debug/common/debug' ;
66
67
import { Variable } from 'vs/workbench/contrib/debug/common/debugModel' ;
67
68
import { ReplGroup } from 'vs/workbench/contrib/debug/common/replModel' ;
68
69
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
@@ -91,6 +92,7 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
91
92
92
93
private history : HistoryNavigator < string > ;
93
94
private tree ! : WorkbenchAsyncDataTree < IDebugSession , IReplElement , FuzzyScore > ;
95
+ private replOptions : ReplOptions ;
94
96
private previousTreeScrollHeight : number = 0 ;
95
97
private replDelegate ! : ReplDelegate ;
96
98
private container ! : HTMLElement ;
@@ -141,6 +143,8 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
141
143
this . filterState = new ReplFilterState ( this ) ;
142
144
this . filter . filterQuery = this . filterState . filterText = this . storageService . get ( FILTER_VALUE_STORAGE_KEY , StorageScope . WORKSPACE , '' ) ;
143
145
this . multiSessionRepl = CONTEXT_MULTI_SESSION_REPL . bindTo ( contextKeyService ) ;
146
+ this . replOptions = this . _register ( this . instantiationService . createInstance ( ReplOptions , this . id , ( ) => this . getBackgroundColor ( ) ) ) ;
147
+ this . _register ( this . replOptions . onDidChange ( ( ) => this . onDidStyleChange ( ) ) ) ;
144
148
145
149
codeEditorService . registerDecorationType ( 'repl-decoration' , DECORATION_KEY , { } ) ;
146
150
this . multiSessionRepl . set ( this . isMultiSessionView ) ;
@@ -191,8 +195,6 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
191
195
this . treeContainer . innerText = '' ;
192
196
dom . clearNode ( this . treeContainer ) ;
193
197
this . createReplTree ( ) ;
194
- } else if ( e . affectsConfiguration ( 'debug.console.lineHeight' ) || e . affectsConfiguration ( 'debug.console.fontSize' ) || e . affectsConfiguration ( 'debug.console.fontFamily' ) ) {
195
- this . onDidStyleChange ( ) ;
196
198
}
197
199
if ( e . affectsConfiguration ( 'debug.console.acceptSuggestionOnEnter' ) ) {
198
200
const config = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) ;
@@ -202,16 +204,6 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
202
204
}
203
205
} ) ) ;
204
206
205
- this . _register ( this . themeService . onDidColorThemeChange ( e => {
206
- this . onDidStyleChange ( ) ;
207
- } ) ) ;
208
-
209
- this . _register ( this . viewDescriptorService . onDidChangeLocation ( e => {
210
- if ( e . views . some ( v => v . id === this . id ) ) {
211
- this . onDidStyleChange ( ) ;
212
- }
213
- } ) ) ;
214
-
215
207
this . _register ( this . editorService . onDidActiveEditorChange ( ( ) => {
216
208
this . setMode ( ) ;
217
209
} ) ) ;
@@ -346,16 +338,10 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
346
338
347
339
private onDidStyleChange ( ) : void {
348
340
if ( this . styleElement ) {
349
- const debugConsole = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) . console ;
350
- const fontSize = debugConsole . fontSize ;
351
- const fontFamily = debugConsole . fontFamily === 'default' ? 'var(--monaco-monospace-font)' : `${ debugConsole . fontFamily } ` ;
352
- const lineHeight = debugConsole . lineHeight ? `${ debugConsole . lineHeight } px` : '1.4em' ;
353
- const backgroundColor = this . themeService . getColorTheme ( ) . getColor ( this . getBackgroundColor ( ) ) ;
354
-
355
341
this . replInput . updateOptions ( {
356
- fontSize,
357
- lineHeight : debugConsole . lineHeight ,
358
- fontFamily : debugConsole . fontFamily === 'default' ? EDITOR_FONT_DEFAULTS . fontFamily : debugConsole . fontFamily
342
+ fontSize : this . replOptions . replConfiguration . fontSize ,
343
+ lineHeight : this . replOptions . replConfiguration . lineHeight ,
344
+ fontFamily : this . replOptions . replConfiguration . fontFamily === 'default' ? EDITOR_FONT_DEFAULTS . fontFamily : this . replOptions . replConfiguration . fontFamily
359
345
} ) ;
360
346
361
347
const replInputLineHeight = this . replInput . getOption ( EditorOption . lineHeight ) ;
@@ -367,13 +353,14 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
367
353
}
368
354
369
355
.repl .repl-input-wrapper .monaco-editor .lines-content {
370
- background-color: ${ backgroundColor } ;
356
+ background-color: ${ this . replOptions . replConfiguration . backgroundColor } ;
371
357
}
372
358
` ;
373
- this . container . style . setProperty ( `--vscode-repl-font-family` , fontFamily ) ;
374
- this . container . style . setProperty ( `--vscode-repl-font-size` , `${ fontSize } px` ) ;
375
- this . container . style . setProperty ( `--vscode-repl-font-size-for-twistie` , `${ fontSize * 1.4 / 2 - 8 } px` ) ;
376
- this . container . style . setProperty ( `--vscode-repl-line-height` , lineHeight ) ;
359
+ const cssFontFamily = this . replOptions . replConfiguration . fontFamily === 'default' ? 'var(--monaco-monospace-font)' : this . replOptions . replConfiguration . fontFamily ;
360
+ this . container . style . setProperty ( `--vscode-repl-font-family` , cssFontFamily ) ;
361
+ this . container . style . setProperty ( `--vscode-repl-font-size` , `${ this . replOptions . replConfiguration . fontSize } px` ) ;
362
+ this . container . style . setProperty ( `--vscode-repl-font-size-for-twistie` , `${ this . replOptions . replConfiguration . fontSizeForTwistie } px` ) ;
363
+ this . container . style . setProperty ( `--vscode-repl-line-height` , this . replOptions . replConfiguration . cssLineHeight ) ;
377
364
378
365
this . tree . rerender ( ) ;
379
366
@@ -566,7 +553,7 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
566
553
}
567
554
568
555
private createReplTree ( ) : void {
569
- this . replDelegate = new ReplDelegate ( this . configurationService ) ;
556
+ this . replDelegate = new ReplDelegate ( this . configurationService , this . replOptions ) ;
570
557
const wordWrap = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) . console . wordWrap ;
571
558
this . treeContainer . classList . toggle ( 'word-wrap' , wordWrap ) ;
572
559
const linkDetector = this . instantiationService . createInstance ( LinkDetector ) ;
@@ -750,6 +737,54 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
750
737
}
751
738
}
752
739
740
+ class ReplOptions extends Disposable implements IReplOptions {
741
+ private static readonly lineHeightEm = 1.4 ;
742
+
743
+ private readonly _onDidChange = this . _register ( new Emitter < void > ( ) ) ;
744
+ readonly onDidChange = this . _onDidChange . event ;
745
+
746
+ private _replConfig ! : IReplConfiguration ;
747
+ public get replConfiguration ( ) : IReplConfiguration {
748
+ return this . _replConfig ;
749
+ }
750
+
751
+ constructor (
752
+ viewId : string ,
753
+ private readonly backgroundColorDelegate : ( ) => string ,
754
+ @IConfigurationService private readonly configurationService : IConfigurationService ,
755
+ @IThemeService private readonly themeService : IThemeService ,
756
+ @IViewDescriptorService private readonly viewDescriptorService : IViewDescriptorService
757
+ ) {
758
+ super ( ) ;
759
+
760
+ this . _register ( this . themeService . onDidColorThemeChange ( e => this . update ( ) ) ) ;
761
+ this . _register ( this . viewDescriptorService . onDidChangeLocation ( e => {
762
+ if ( e . views . some ( v => v . id === viewId ) ) {
763
+ this . update ( ) ;
764
+ }
765
+ } ) ) ;
766
+ this . _register ( this . configurationService . onDidChangeConfiguration ( e => {
767
+ if ( e . affectsConfiguration ( 'debug.console.lineHeight' ) || e . affectsConfiguration ( 'debug.console.fontSize' ) || e . affectsConfiguration ( 'debug.console.fontFamily' ) ) {
768
+ this . update ( ) ;
769
+ }
770
+ } ) ) ;
771
+ this . update ( ) ;
772
+ }
773
+
774
+ private update ( ) {
775
+ const debugConsole = this . configurationService . getValue < IDebugConfiguration > ( 'debug' ) . console ;
776
+ this . _replConfig = {
777
+ fontSize : debugConsole . fontSize ,
778
+ fontFamily : debugConsole . fontFamily ,
779
+ lineHeight : debugConsole . lineHeight ? debugConsole . lineHeight : ReplOptions . lineHeightEm * debugConsole . fontSize ,
780
+ cssLineHeight : debugConsole . lineHeight ? `${ debugConsole . lineHeight } px` : `${ ReplOptions . lineHeightEm } em` ,
781
+ backgroundColor : this . themeService . getColorTheme ( ) . getColor ( this . backgroundColorDelegate ( ) ) ,
782
+ fontSizeForTwistie : debugConsole . fontSize * ReplOptions . lineHeightEm / 2 - 8
783
+ } ;
784
+ this . _onDidChange . fire ( ) ;
785
+ }
786
+ }
787
+
753
788
// Repl actions and commands
754
789
755
790
class AcceptReplInputAction extends EditorAction {
0 commit comments