Skip to content

Commit 32abf92

Browse files
committed
Fix config defaults
For some reason, when a string config option isn't specified it gets a default value of `""`, so when we checked the new config option, the empty string value would get chosen instead. So I added a default of null for the old options, and I also switched the existing defaults to the new options, choosing the old options first if they're present.
1 parent 39f7278 commit 32abf92

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"smithyLsp.version": {
109109
"scope": "window",
110110
"type": "string",
111-
"default": "0.6.0",
111+
"default": null,
112112
"description": "Version of the Smithy Language Server (see https://github.com/smithy-lang/smithy-language-server).",
113113
"deprecationMessage": "Use smithy.server.version instead."
114114
},
@@ -121,7 +121,7 @@
121121
"DANGER",
122122
"ERROR"
123123
],
124-
"default": "WARNING",
124+
"default": null,
125125
"description": "Minimum severity of Smithy validation events to display in the editor.",
126126
"deprecationMessage": "Use smithy.server.diagnostics.minimumSeverity instead."
127127
},
@@ -150,10 +150,12 @@
150150
},
151151
"smithy.server.executable": {
152152
"type": "string",
153+
"default": null,
153154
"description": "Executable to run the Smithy Language Server. Can be the executable name if it is on your PATH, or an absolute path to the executable."
154155
},
155156
"smithy.server.version": {
156157
"type": "string",
158+
"default": "0.6.0",
157159
"description": "Version of the Smithy Language Server to use. Ignored if smithy.server.executable is provided."
158160
},
159161
"smithy.server.diagnostics.minimumSeverity": {

src/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode';
22

33
export function getServerDiagnosticsMinimumSeverity(): string | undefined {
4-
return getConfig('server.diagnostics.minimumSeverity') ?? getOldConfig('diagnostics.minimumSeverity');
4+
return getOldOrNewConfig('diagnostics.minimumSeverity', 'server.diagnostics.minimumSeverity');
55
}
66

77
export function getServerOnlyReloadOnSave(): boolean | undefined {
@@ -13,7 +13,11 @@ export function getServerExecutable(): string | undefined {
1313
}
1414

1515
export function getServerVersion(): string {
16-
return getConfig('server.version') ?? getOldConfig('version');
16+
return getOldOrNewConfig('version', 'server.version');
17+
}
18+
19+
function getOldOrNewConfig<T>(oldKey: string, newKey: string): T | undefined {
20+
return getOldConfig(oldKey) || getConfig(newKey);
1721
}
1822

1923
function getConfig<T>(key: string): T | undefined {

0 commit comments

Comments
 (0)