@@ -11,7 +11,9 @@ export type RunnableEnvCfg =
1111
1212export class Config {
1313 readonly extensionId = "rust-lang.rust-analyzer" ;
14- configureLang : vscode . Disposable | undefined ;
14+ configureLang :
15+ | { handle : vscode . Disposable ; typingContinueCommentsOnNewline : boolean }
16+ | undefined ;
1517
1618 readonly rootSection = "rust-analyzer" ;
1719 private readonly requiresReloadOpts = [
@@ -43,7 +45,7 @@ export class Config {
4345 }
4446
4547 dispose ( ) {
46- this . configureLang ?. dispose ( ) ;
48+ this . configureLang ?. handle . dispose ( ) ;
4749 }
4850
4951 private refreshLogging ( ) {
@@ -86,7 +88,15 @@ export class Config {
8688 * [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
8789 */
8890 private configureLanguage ( ) {
89- if ( this . configureLang ) return ;
91+ // Only need to dispose of the config if there's a change
92+ if (
93+ this . configureLang &&
94+ this . typingContinueCommentsOnNewline !==
95+ this . configureLang . typingContinueCommentsOnNewline
96+ ) {
97+ this . configureLang . handle . dispose ( ) ;
98+ this . configureLang = undefined ;
99+ }
90100
91101 let onEnterRules : vscode . OnEnterRule [ ] = [
92102 {
@@ -157,9 +167,12 @@ export class Config {
157167 ] ;
158168 }
159169
160- this . configureLang = vscode . languages . setLanguageConfiguration ( "rust" , {
161- onEnterRules,
162- } ) ;
170+ this . configureLang = {
171+ handle : vscode . languages . setLanguageConfiguration ( "rust" , {
172+ onEnterRules,
173+ } ) ,
174+ typingContinueCommentsOnNewline : this . typingContinueCommentsOnNewline ,
175+ } ;
163176 }
164177
165178 // We don't do runtime config validation here for simplicity. More on stackoverflow:
0 commit comments