Auto merge of #12934 - Veykril:typing, r=Veykril

Add a setting to disable comment continuation in VSCode

Fixes https://github.com/rust-lang/rust-analyzer/issues/12928
This commit is contained in:
bors 2022-08-03 16:23:49 +00:00
commit 4904b2bdf8
3 changed files with 19 additions and 4 deletions

View file

@ -380,6 +380,11 @@
"default": false, "default": false,
"type": "boolean" "type": "boolean"
}, },
"rust-analyzer.typing.continueCommentsOnNewline": {
"markdownDescription": "Whether to prefix newlines after comments with the corresponding comment prefix.",
"default": true,
"type": "boolean"
},
"$generated-start": {}, "$generated-start": {},
"rust-analyzer.assist.expressionFillDefault": { "rust-analyzer.assist.expressionFillDefault": {
"markdownDescription": "Placeholder expression to use for missing expressions in assists.", "markdownDescription": "Placeholder expression to use for missing expressions in assists.",

View file

@ -16,9 +16,13 @@ export class Config {
readonly extensionId = "rust-lang.rust-analyzer"; readonly extensionId = "rust-lang.rust-analyzer";
readonly rootSection = "rust-analyzer"; readonly rootSection = "rust-analyzer";
private readonly requiresWorkspaceReloadOpts = ["serverPath", "server"].map( private readonly requiresWorkspaceReloadOpts = [
(opt) => `${this.rootSection}.${opt}` "serverPath",
); "server",
// FIXME: This shouldn't be here, changing this setting should reload
// `continueCommentsOnNewline` behavior without restart
"typing",
].map((opt) => `${this.rootSection}.${opt}`);
private readonly requiresReloadOpts = [ private readonly requiresReloadOpts = [
"cargo", "cargo",
"procMacro", "procMacro",
@ -140,6 +144,10 @@ export class Config {
return this.get<boolean>("restartServerOnConfigChange"); return this.get<boolean>("restartServerOnConfigChange");
} }
get typingContinueCommentsOnNewline() {
return this.get<boolean>("typing.continueCommentsOnNewline");
}
get debug() { get debug() {
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap"); let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
if (sourceFileMap !== "auto") { if (sourceFileMap !== "auto") {

View file

@ -84,7 +84,9 @@ async function tryActivate(context: vscode.ExtensionContext): Promise<RustAnalyz
warnAboutExtensionConflicts(); warnAboutExtensionConflicts();
ctx.pushCleanup(configureLanguage()); if (config.typingContinueCommentsOnNewline) {
ctx.pushCleanup(configureLanguage());
}
vscode.workspace.onDidChangeConfiguration( vscode.workspace.onDidChangeConfiguration(
(_) => (_) =>