Skip to content
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

WorkspaceConfiguration update and inspect methods fail if section is undefined #12043

Closed
t1m0thyj opened this issue Jan 5, 2023 · 0 comments · Fixed by #12056
Closed

WorkspaceConfiguration update and inspect methods fail if section is undefined #12043

t1m0thyj opened this issue Jan 5, 2023 · 0 comments · Fixed by #12056
Labels
preferences issues related to preferences vscode issues related to VSCode compatibility

Comments

@t1m0thyj
Copy link

t1m0thyj commented Jan 5, 2023

Bug Description:

When vscode.workspace.getConfiguration() is called without providing a section identifier, then the update and inspect methods add an extra "undefined." in front of the dotted property name.

Expected behavior: config.update("x.y.z", true) should add the line "x.y.z": true to settings.json
Actual behavior: config.update("x.y.z", true) adds the line "undefined.x.y.z": true

Steps to Reproduce:

  1. Create a VS Code extension that inspects/updates configuration values and install it into Theia. For example, add this code snippet:

    let config = vscode.workspace.getConfiguration();
    console.log(config.inspect("editor.tabSize"));
    await config.update("editor.tabSize", 8, vscode.ConfigurationTarget.Global);
    config = vscode.workspace.getConfiguration("editor");
    console.log(config.inspect("tabSize"));
    await config.update("tabSize", 8, vscode.ConfigurationTarget.Global);
  2. Note that the first object logged to the console is wrong - the "defaultValue" should be 4 like the second object:

    2023-01-05T19:09:37.873Z root INFO [hosted-plugin: 44] {
      key: 'editor.tabSize',
      defaultValue: undefined,
      globalValue: undefined,
      workspaceValue: undefined,
      workspaceFolderValue: undefined
    }
    2023-01-05T19:09:38.059Z root INFO [hosted-plugin: 44] {
      key: 'tabSize',
      defaultValue: 4,
      globalValue: undefined,
      workspaceValue: undefined,
      workspaceFolderValue: undefined
    }
    
  3. Also note that the contents of settings.json are wrong - the first property that starts with "undefined." is invalid:

    {
        "undefined.editor.tabSize": 8,
        "editor.tabSize": 8
    }

Additional Information

  • Operating System: Alpine Linux (Docker)
  • Theia Version: 1.33.0

I believe this is a regression that was introduced in #11393, and Theia 1.29.0 was the first version with this issue. In the following places, rawSection should not be hardcoded in case it is undefined:

update: (key: string, value: any, targetScope?: ConfigurationTarget | boolean, withLanguageOverride?: boolean): PromiseLike<void> => {
const resourceStr = overrides.resource?.toString();
const fullPath = `${overrides.overrideIdentifier ? `[${overrides.overrideIdentifier}].` : ''}${rawSection}.${key}`;

inspect: <T>(key: string): ConfigurationInspect<T> | undefined => {
const path = `${rawSection}.${key}`;

@vince-fugnitto vince-fugnitto added preferences issues related to preferences vscode issues related to VSCode compatibility labels Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preferences issues related to preferences vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants