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

onDidChangeConfiguration overwrites all settings instead of just changed settings, breaking Helix support #9

Closed
dansalvato opened this issue May 24, 2023 · 1 comment

Comments

@dansalvato
Copy link
Contributor

dansalvato commented May 24, 2023

async onDidChangeConfiguration() {
const newConfig = await this.ctx.connection.workspace.getConfiguration(
"m68k"
);
this.ctx.config = mergeDefaults(newConfig);
}

According to LSP spec, onDidChangeConfiguration only provides changed settings, but the above function assumes that all settings are being provided.

This discrepancy causes m68k-lsp-server to not work properly in the Helix editor, because Helix sends multiple onDidChangeConfiguration calls which causes the LSP to overwrite the user's initialization options with the defaults.

I confirmed that this workaround successfully fixes Helix support:

  async onDidChangeConfiguration() {
    const oldConfig = this.ctx.config;
    const newConfig = await this.ctx.connection.workspace.getConfiguration(
      "m68k"
    );
    this.ctx.config = {
      ...oldConfig,
      ...newConfig,
      format: {
        ...oldConfig.format,
        ...newConfig?.format,
        align: {
          ...oldConfig.format.align,
          ...newConfig?.format?.align,
        },
      },
      vasm: {
        ...oldConfig.vasm,
        ...newConfig?.vasm,
      },
    };
  }
@grahambates
Copy link
Owner

Thanks for this. I'll get it fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants