Skip to content

Commit 1dc489a

Browse files
authored
Allow also minimum and maximum on editor float options (microsoft#254856)
allowing also minimum and maximum on editor float options
1 parent fe3803e commit 1dc489a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/vs/editor/common/config/editorOptions.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,9 @@ export function clampedFloat<T extends number>(value: any, defaultValue: T, mini
12561256

12571257
class EditorFloatOption<K extends EditorOption> extends SimpleEditorOption<K, number> {
12581258

1259+
public readonly minimum: number | undefined;
1260+
public readonly maximum: number | undefined;
1261+
12591262
public static clamp(n: number, min: number, max: number): number {
12601263
if (n < min) {
12611264
return min;
@@ -1279,13 +1282,17 @@ class EditorFloatOption<K extends EditorOption> extends SimpleEditorOption<K, nu
12791282

12801283
public readonly validationFn: (value: number) => number;
12811284

1282-
constructor(id: K, name: PossibleKeyName<number>, defaultValue: number, validationFn: (value: number) => number, schema?: IConfigurationPropertySchema) {
1285+
constructor(id: K, name: PossibleKeyName<number>, defaultValue: number, validationFn: (value: number) => number, schema?: IConfigurationPropertySchema, minimum?: number, maximum?: number) {
12831286
if (typeof schema !== 'undefined') {
12841287
schema.type = 'number';
12851288
schema.default = defaultValue;
1289+
schema.minimum = minimum;
1290+
schema.maximum = maximum;
12861291
}
12871292
super(id, name, defaultValue, schema);
12881293
this.validationFn = validationFn;
1294+
this.minimum = minimum;
1295+
this.maximum = maximum;
12891296
}
12901297

12911298
public override validate(input: any): number {
@@ -3203,7 +3210,9 @@ class EditorLineHeight extends EditorFloatOption<EditorOption.lineHeight> {
32033210
EditorOption.lineHeight, 'lineHeight',
32043211
EDITOR_FONT_DEFAULTS.lineHeight,
32053212
x => EditorFloatOption.clamp(x, 0, 150),
3206-
{ markdownDescription: nls.localize('lineHeight', "Controls the line height. \n - Use 0 to automatically compute the line height from the font size.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values.") }
3213+
{ markdownDescription: nls.localize('lineHeight', "Controls the line height. \n - Use 0 to automatically compute the line height from the font size.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values.") },
3214+
0,
3215+
150
32073216
);
32083217
}
32093218

0 commit comments

Comments
 (0)