-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not allow *.path
options to be null
#198
Conversation
Allowing the values to be null disables setting the values in the settings UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing the values to be null disables setting the values in the settings UI.
I really to tried to test my changes as much as possible but using the settings UI never crossed my mind...
There are still many locations where get<string | null>("path", null)
happens. Those need to be adjusted for this change.
Last time I checked, the default value for a string option is not undefined
but ""
which means that the following change should be applied in most cases.
- configuration.get<string | null>("path", null);
+ configuration.get<string>("path") ?? null;
+ configuration.get<string>("path") ?? undefined; // when calling getExePath
Most importantly, this code needs to be adjusted or removed entirely.
I'd be happy to work on these changes myself if you'd like.
I'd expect the opposite to be true but I'll have to check. |
Setting the default value to diff --git a/package.json b/package.json
index 5b9164c..5e80a93 100644
--- a/package.json
+++ b/package.json
@@ -68,6 +68,11 @@
"type": "object",
"title": "Zig",
"properties": {
+ "zig.testOption": {
+ "type": "string",
+ "default": null,
+ "description": "just testing"
+ },
"zig.initialSetupDone": {
"type": "boolean",
"default": false,
diff --git a/src/zigSetup.ts b/src/zigSetup.ts
index 8ab9314..9fd3908 100644
--- a/src/zigSetup.ts
+++ b/src/zigSetup.ts
@@ -264,6 +264,9 @@ export async function setupZig(context: vscode.ExtensionContext) {
);
const configuration = vscode.workspace.getConfiguration("zig");
+ void vscode.window.showInformationMessage(`testOption=${(configuration.get<string | null>("testOption", null) === null).toString()}`, {
+ modal: true,
+ });
if (!configuration.get<boolean>("initialSetupDone")) {
await configuration.update("initialSetupDone", await initialSetup(context), true);
}
|
Doesn't this bring us back to #166 again? |
I don't think so? |
I mean that having null as the default value will make VS Code show a warning because null is not a valid string which was one of the issues that the PR I mentioned wanted to fix. "zig.testOption": {
"type": "string",
"default": null,
"description": "just testing"
}, |
I wouldn't expect anyone to actually set the option with null but I guess I'll have to do it the javascript way and treat empty string as null. |
Adding types doesn't actually make `undefined`, `null` and `""` different things.
Allowing the values to be null disables setting the values in the settings UI.