mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix change detection for relevant lang config opts
This commit is contained in:
parent
1c454736a4
commit
992bafa773
1 changed files with 19 additions and 6 deletions
|
@ -11,7 +11,9 @@ export type RunnableEnvCfg =
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
readonly extensionId = "rust-lang.rust-analyzer";
|
readonly extensionId = "rust-lang.rust-analyzer";
|
||||||
configureLang: vscode.Disposable | undefined;
|
configureLang:
|
||||||
|
| { handle: vscode.Disposable; typingContinueCommentsOnNewline: boolean }
|
||||||
|
| undefined;
|
||||||
|
|
||||||
readonly rootSection = "rust-analyzer";
|
readonly rootSection = "rust-analyzer";
|
||||||
private readonly requiresReloadOpts = [
|
private readonly requiresReloadOpts = [
|
||||||
|
@ -43,7 +45,7 @@ export class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.configureLang?.dispose();
|
this.configureLang?.handle.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private refreshLogging() {
|
private refreshLogging() {
|
||||||
|
@ -86,7 +88,15 @@ export class Config {
|
||||||
* [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
|
* [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
|
||||||
*/
|
*/
|
||||||
private configureLanguage() {
|
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[] = [
|
let onEnterRules: vscode.OnEnterRule[] = [
|
||||||
{
|
{
|
||||||
|
@ -157,9 +167,12 @@ export class Config {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.configureLang = vscode.languages.setLanguageConfiguration("rust", {
|
this.configureLang = {
|
||||||
onEnterRules,
|
handle: vscode.languages.setLanguageConfiguration("rust", {
|
||||||
});
|
onEnterRules,
|
||||||
|
}),
|
||||||
|
typingContinueCommentsOnNewline: this.typingContinueCommentsOnNewline,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't do runtime config validation here for simplicity. More on stackoverflow:
|
// We don't do runtime config validation here for simplicity. More on stackoverflow:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue