Skip to content

Commit 59e4b45

Browse files
committed
Fixes microsoft#94931: Handle null values
1 parent e7bc301 commit 59e4b45

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ class EditorComments extends BaseEditorOption<EditorOption.comments, EditorComme
10671067
}
10681068

10691069
public validate(_input: any): EditorCommentsOptions {
1070-
if (typeof _input !== 'object') {
1070+
if (!_input || typeof _input !== 'object') {
10711071
return this.defaultValue;
10721072
}
10731073
const input = _input as IEditorCommentsOptions;
@@ -1312,7 +1312,7 @@ class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions>
13121312
}
13131313

13141314
public validate(_input: any): EditorFindOptions {
1315-
if (typeof _input !== 'object') {
1315+
if (!_input || typeof _input !== 'object') {
13161316
return this.defaultValue;
13171317
}
13181318
const input = _input as IEditorFindOptions;
@@ -1538,7 +1538,7 @@ class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoT
15381538
}
15391539

15401540
public validate(_input: any): GoToLocationOptions {
1541-
if (typeof _input !== 'object') {
1541+
if (!_input || typeof _input !== 'object') {
15421542
return this.defaultValue;
15431543
}
15441544
const input = _input as IGotoLocationOptions;
@@ -1616,7 +1616,7 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
16161616
}
16171617

16181618
public validate(_input: any): EditorHoverOptions {
1619-
if (typeof _input !== 'object') {
1619+
if (!_input || typeof _input !== 'object') {
16201620
return this.defaultValue;
16211621
}
16221622
const input = _input as IEditorHoverOptions;
@@ -2042,7 +2042,7 @@ class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLig
20422042
}
20432043

20442044
public validate(_input: any): EditorLightbulbOptions {
2045-
if (typeof _input !== 'object') {
2045+
if (!_input || typeof _input !== 'object') {
20462046
return this.defaultValue;
20472047
}
20482048
const input = _input as IEditorLightbulbOptions;
@@ -2186,7 +2186,7 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
21862186
}
21872187

21882188
public validate(_input: any): EditorMinimapOptions {
2189-
if (typeof _input !== 'object') {
2189+
if (!_input || typeof _input !== 'object') {
21902190
return this.defaultValue;
21912191
}
21922192
const input = _input as IEditorMinimapOptions;
@@ -2261,7 +2261,7 @@ class EditorPadding extends BaseEditorOption<EditorOption.padding, InternalEdito
22612261
}
22622262

22632263
public validate(_input: any): InternalEditorPaddingOptions {
2264-
if (typeof _input !== 'object') {
2264+
if (!_input || typeof _input !== 'object') {
22652265
return this.defaultValue;
22662266
}
22672267
const input = _input as IEditorPaddingOptions;
@@ -2319,7 +2319,7 @@ class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints,
23192319
}
23202320

23212321
public validate(_input: any): InternalParameterHintOptions {
2322-
if (typeof _input !== 'object') {
2322+
if (!_input || typeof _input !== 'object') {
23232323
return this.defaultValue;
23242324
}
23252325
const input = _input as IEditorParameterHintOptions;
@@ -2409,7 +2409,7 @@ class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggesti
24092409
if (typeof _input === 'boolean') {
24102410
return _input;
24112411
}
2412-
if (typeof _input === 'object') {
2412+
if (_input && typeof _input === 'object') {
24132413
const input = _input as IQuickSuggestionsOptions;
24142414
const opts = {
24152415
other: EditorBooleanOption.boolean(input.other, this.defaultValue.other),
@@ -2559,7 +2559,7 @@ class EditorRulers extends BaseEditorOption<EditorOption.rulers, IRulerOption[]>
25592559
column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
25602560
color: null
25612561
});
2562-
} else if (typeof _element === 'object') {
2562+
} else if (_element && typeof _element === 'object') {
25632563
const element = _element as IRulerOption;
25642564
rulers.push({
25652565
column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
@@ -2693,7 +2693,7 @@ class EditorScrollbar extends BaseEditorOption<EditorOption.scrollbar, InternalE
26932693
}
26942694

26952695
public validate(_input: any): InternalEditorScrollbarOptions {
2696-
if (typeof _input !== 'object') {
2696+
if (!_input || typeof _input !== 'object') {
26972697
return this.defaultValue;
26982698
}
26992699
const input = _input as IEditorScrollbarOptions;
@@ -3114,7 +3114,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
31143114
}
31153115

31163116
public validate(_input: any): InternalSuggestOptions {
3117-
if (typeof _input !== 'object') {
3117+
if (!_input || typeof _input !== 'object') {
31183118
return this.defaultValue;
31193119
}
31203120
const input = _input as ISuggestOptions;

src/vs/editor/test/common/config/commonEditorConfig.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55
import * as assert from 'assert';
66
import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig';
7-
import { IEditorHoverOptions, EditorOption, ConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
7+
import { IEditorHoverOptions, EditorOption, ConfigurationChangedEvent, IQuickSuggestionsOptions } from 'vs/editor/common/config/editorOptions';
88
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
99
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
1010
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
@@ -201,4 +201,14 @@ suite('Common Editor Config', () => {
201201
config.updateOptions({ roundedSelection: false });
202202
assert.equal(event, null);
203203
});
204+
205+
test('issue #94931: Unable to open source file', () => {
206+
const config = new TestConfiguration({ quickSuggestions: null! });
207+
const actual = <Readonly<Required<IQuickSuggestionsOptions>>>config.options.get(EditorOption.quickSuggestions);
208+
assert.deepEqual(actual, {
209+
other: true,
210+
comments: false,
211+
strings: false
212+
});
213+
});
204214
});

0 commit comments

Comments
 (0)