Skip to content

Commit

Permalink
don't send default config values to ZLS
Browse files Browse the repository at this point in the history
This will prevent config options set in the zls.json from being
overridden with default values by the extension.

VS Code, in their infinite wisdom, has chosen to default boolean config
options to false and string options to an empty string (""), ensuring
that null or undefined are never returned.

See zigtools/zls#2135
  • Loading branch information
Techatrix committed Feb 6, 2025
1 parent 6bbd98e commit 2a78bb3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/zls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ async function configurationMiddleware(
// Make sure that `""` gets converted to `null` and resolve predefined values
result[index] = configValue ? handleConfigOption(configValue) : null;
}

const inspect = configuration.inspect(section);
const isDefaultValue =
configValue === inspect?.defaultValue &&
inspect?.globalValue === undefined &&
inspect?.workspaceValue === undefined &&
inspect?.workspaceFolderValue === undefined;
if(isDefaultValue) {
result[index] = null;
}
}

const indexOfZigPath = optionIndices["zig.path"];
Expand Down

0 comments on commit 2a78bb3

Please sign in to comment.