grahambates/m68k-lsp

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

dansalvato opened this issue · 1 comments

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,
      },
    };
  }

Thanks for this. I'll get it fixed.