Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to disable comment continuation in VSCode #12934

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@
"default": false,
"type": "boolean"
},
"rust-analyzer.typing.continueCommentsOnNewline": {
"markdownDescription": "Whether to prefix newlines after comments with the corresponding comment prefix.",
"default": true,
"type": "boolean"
},
"$generated-start": {},
"rust-analyzer.assist.expressionFillDefault": {
"markdownDescription": "Placeholder expression to use for missing expressions in assists.",
Expand Down
14 changes: 11 additions & 3 deletions editors/code/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ export class Config {
readonly extensionId = "rust-lang.rust-analyzer";

readonly rootSection = "rust-analyzer";
private readonly requiresWorkspaceReloadOpts = ["serverPath", "server"].map(
(opt) => `${this.rootSection}.${opt}`
);
private readonly requiresWorkspaceReloadOpts = [
"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 = [
"cargo",
"procMacro",
Expand Down Expand Up @@ -140,6 +144,10 @@ export class Config {
return this.get<boolean>("restartServerOnConfigChange");
}

get typingContinueCommentsOnNewline() {
return this.get<boolean>("typing.continueCommentsOnNewline");
}

get debug() {
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
if (sourceFileMap !== "auto") {
Expand Down
4 changes: 3 additions & 1 deletion editors/code/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ async function tryActivate(context: vscode.ExtensionContext): Promise<RustAnalyz

warnAboutExtensionConflicts();

ctx.pushCleanup(configureLanguage());
if (config.typingContinueCommentsOnNewline) {
ctx.pushCleanup(configureLanguage());
}

vscode.workspace.onDidChangeConfiguration(
(_) =>
Expand Down