@@ -57,6 +57,10 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
57
57
return this . _configurationService . getValue ( TerminalSettingId . FontSize ) ;
58
58
}
59
59
60
+ private _clampFontSize ( fontSize : number ) : number {
61
+ return clampTerminalFontSize ( fontSize ) ;
62
+ }
63
+
60
64
private _setupMouseWheelZoomListener ( raw : RawXtermTerminal ) {
61
65
// This is essentially a copy of what we do in the editor, just we modify font size directly
62
66
// as there is no separate zoom level concept in the terminal
@@ -72,7 +76,8 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
72
76
if ( classifier . isPhysicalMouseWheel ( ) ) {
73
77
if ( this . _hasMouseWheelZoomModifiers ( browserEvent ) ) {
74
78
const delta = browserEvent . deltaY > 0 ? - 1 : 1 ;
75
- this . _configurationService . updateValue ( TerminalSettingId . FontSize , this . _getConfigFontSize ( ) + delta ) ;
79
+ const newFontSize = this . _clampFontSize ( this . _getConfigFontSize ( ) + delta ) ;
80
+ this . _configurationService . updateValue ( TerminalSettingId . FontSize , newFontSize ) ;
76
81
// EditorZoom.setZoomLevel(zoomLevel + delta);
77
82
browserEvent . preventDefault ( ) ;
78
83
browserEvent . stopPropagation ( ) ;
@@ -96,7 +101,8 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
96
101
const deltaAbs = Math . ceil ( Math . abs ( gestureAccumulatedDelta / 5 ) ) ;
97
102
const deltaDirection = gestureAccumulatedDelta > 0 ? - 1 : 1 ;
98
103
const delta = deltaAbs * deltaDirection ;
99
- this . _configurationService . updateValue ( TerminalSettingId . FontSize , gestureStartFontSize + delta ) ;
104
+ const newFontSize = this . _clampFontSize ( gestureStartFontSize + delta ) ;
105
+ this . _configurationService . updateValue ( TerminalSettingId . FontSize , newFontSize ) ;
100
106
gestureAccumulatedDelta += browserEvent . deltaY ;
101
107
browserEvent . preventDefault ( ) ;
102
108
browserEvent . stopPropagation ( ) ;
@@ -128,7 +134,8 @@ registerTerminalAction({
128
134
const configurationService = accessor . get ( IConfigurationService ) ;
129
135
const value = configurationService . getValue ( TerminalSettingId . FontSize ) ;
130
136
if ( isNumber ( value ) ) {
131
- await configurationService . updateValue ( TerminalSettingId . FontSize , value + 1 ) ;
137
+ const newFontSize = clampTerminalFontSize ( value + 1 ) ;
138
+ await configurationService . updateValue ( TerminalSettingId . FontSize , newFontSize ) ;
132
139
}
133
140
}
134
141
} ) ;
@@ -140,7 +147,8 @@ registerTerminalAction({
140
147
const configurationService = accessor . get ( IConfigurationService ) ;
141
148
const value = configurationService . getValue ( TerminalSettingId . FontSize ) ;
142
149
if ( isNumber ( value ) ) {
143
- await configurationService . updateValue ( TerminalSettingId . FontSize , value - 1 ) ;
150
+ const newFontSize = clampTerminalFontSize ( value - 1 ) ;
151
+ await configurationService . updateValue ( TerminalSettingId . FontSize , newFontSize ) ;
144
152
}
145
153
}
146
154
} ) ;
@@ -153,3 +161,7 @@ registerTerminalAction({
153
161
await configurationService . updateValue ( TerminalSettingId . FontSize , defaultTerminalFontSize ) ;
154
162
}
155
163
} ) ;
164
+
165
+ export function clampTerminalFontSize ( fontSize : number ) : number {
166
+ return Math . max ( 6 , Math . min ( 100 , fontSize ) ) ;
167
+ }
0 commit comments