Skip to content

Commit 4904b2b

Browse files
committed
Auto merge of rust-lang#12934 - Veykril:typing, r=Veykril
Add a setting to disable comment continuation in VSCode Fixes rust-lang/rust-analyzer#12928
2 parents 2bc9a2d + 46d6357 commit 4904b2b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@
380380
"default": false,
381381
"type": "boolean"
382382
},
383+
"rust-analyzer.typing.continueCommentsOnNewline": {
384+
"markdownDescription": "Whether to prefix newlines after comments with the corresponding comment prefix.",
385+
"default": true,
386+
"type": "boolean"
387+
},
383388
"$generated-start": {},
384389
"rust-analyzer.assist.expressionFillDefault": {
385390
"markdownDescription": "Placeholder expression to use for missing expressions in assists.",

editors/code/src/config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ export class Config {
1616
readonly extensionId = "rust-lang.rust-analyzer";
1717

1818
readonly rootSection = "rust-analyzer";
19-
private readonly requiresWorkspaceReloadOpts = ["serverPath", "server"].map(
20-
(opt) => `${this.rootSection}.${opt}`
21-
);
19+
private readonly requiresWorkspaceReloadOpts = [
20+
"serverPath",
21+
"server",
22+
// FIXME: This shouldn't be here, changing this setting should reload
23+
// `continueCommentsOnNewline` behavior without restart
24+
"typing",
25+
].map((opt) => `${this.rootSection}.${opt}`);
2226
private readonly requiresReloadOpts = [
2327
"cargo",
2428
"procMacro",
@@ -140,6 +144,10 @@ export class Config {
140144
return this.get<boolean>("restartServerOnConfigChange");
141145
}
142146

147+
get typingContinueCommentsOnNewline() {
148+
return this.get<boolean>("typing.continueCommentsOnNewline");
149+
}
150+
143151
get debug() {
144152
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
145153
if (sourceFileMap !== "auto") {

editors/code/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ async function tryActivate(context: vscode.ExtensionContext): Promise<RustAnalyz
8484

8585
warnAboutExtensionConflicts();
8686

87-
ctx.pushCleanup(configureLanguage());
87+
if (config.typingContinueCommentsOnNewline) {
88+
ctx.pushCleanup(configureLanguage());
89+
}
8890

8991
vscode.workspace.onDidChangeConfiguration(
9092
(_) =>

0 commit comments

Comments
 (0)