@@ -11,7 +11,9 @@ export type RunnableEnvCfg =
11
11
12
12
export class Config {
13
13
readonly extensionId = "rust-lang.rust-analyzer" ;
14
- configureLang : vscode . Disposable | undefined ;
14
+ configureLang :
15
+ | { handle : vscode . Disposable ; typingContinueCommentsOnNewline : boolean }
16
+ | undefined ;
15
17
16
18
readonly rootSection = "rust-analyzer" ;
17
19
private readonly requiresReloadOpts = [
@@ -43,7 +45,7 @@ export class Config {
43
45
}
44
46
45
47
dispose ( ) {
46
- this . configureLang ?. dispose ( ) ;
48
+ this . configureLang ?. handle . dispose ( ) ;
47
49
}
48
50
49
51
private refreshLogging ( ) {
@@ -86,7 +88,15 @@ export class Config {
86
88
* [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
87
89
*/
88
90
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
+ }
90
100
91
101
let onEnterRules : vscode . OnEnterRule [ ] = [
92
102
{
@@ -157,9 +167,12 @@ export class Config {
157
167
] ;
158
168
}
159
169
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
+ } ;
163
176
}
164
177
165
178
// We don't do runtime config validation here for simplicity. More on stackoverflow:
0 commit comments