diff options
| author | DropDemBits <r3usrlnd@gmail.com> | 2023-01-17 16:25:46 -0500 |
|---|---|---|
| committer | DropDemBits <r3usrlnd@gmail.com> | 2023-01-17 16:41:33 -0500 |
| commit | 992bafa773255cf9858bdc25c302abbd07d89c7b (patch) | |
| tree | 3e592106227dc49ab30af3e0075f84f59c3d5bd4 | |
| parent | 1c454736a4f593eebac2c43de9dfb50f9200c250 (diff) | |
| download | rust-992bafa773255cf9858bdc25c302abbd07d89c7b.tar.gz rust-992bafa773255cf9858bdc25c302abbd07d89c7b.zip | |
Fix change detection for relevant lang config opts
| -rw-r--r-- | editors/code/src/config.ts | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 029dc3afd55..30ff9784829 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -11,7 +11,9 @@ export type RunnableEnvCfg = export class Config { readonly extensionId = "rust-lang.rust-analyzer"; - configureLang: vscode.Disposable | undefined; + configureLang: + | { handle: vscode.Disposable; typingContinueCommentsOnNewline: boolean } + | undefined; readonly rootSection = "rust-analyzer"; private readonly requiresReloadOpts = [ @@ -43,7 +45,7 @@ export class Config { } dispose() { - this.configureLang?.dispose(); + this.configureLang?.handle.dispose(); } private refreshLogging() { @@ -86,7 +88,15 @@ export class Config { * [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076 */ private configureLanguage() { - if (this.configureLang) return; + // Only need to dispose of the config if there's a change + if ( + this.configureLang && + this.typingContinueCommentsOnNewline !== + this.configureLang.typingContinueCommentsOnNewline + ) { + this.configureLang.handle.dispose(); + this.configureLang = undefined; + } let onEnterRules: vscode.OnEnterRule[] = [ { @@ -157,9 +167,12 @@ export class Config { ]; } - this.configureLang = vscode.languages.setLanguageConfiguration("rust", { - onEnterRules, - }); + this.configureLang = { + handle: vscode.languages.setLanguageConfiguration("rust", { + onEnterRules, + }), + typingContinueCommentsOnNewline: this.typingContinueCommentsOnNewline, + }; } // We don't do runtime config validation here for simplicity. More on stackoverflow: |
