Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 00a9727

Browse files
committed
automate braceless return substitution for long lines
Per [bjorn3][https://github.com/bjorn3] suggestion resolves cases where an early return is moved to a separate line due to line width formatting. This setting changes ``` if (a very long condition) return; ``` to ``` if (a very long condition) { return; } ``` while keeping ``` if (short) return; ``` as is. In pathological cases this may cause `npm run fix` not to fix formatting in one go and may require running it twice.
1 parent e0df2c9 commit 00a9727

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

editors/code/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
rules: {
1515
camelcase: ["error"],
1616
eqeqeq: ["error", "always", { null: "ignore" }],
17+
curly: ["error", "multi-line"],
1718
"no-console": ["error", { allow: ["warn", "error"] }],
1819
"prefer-const": "error",
1920
"@typescript-eslint/member-delimiter-style": [

editors/code/src/ast_inspector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ export class AstInspector implements vscode.HoverProvider, vscode.DefinitionProv
101101
doc: vscode.TextDocument,
102102
pos: vscode.Position
103103
): vscode.ProviderResult<vscode.DefinitionLink[]> {
104-
if (!this.rustEditor || doc.uri.toString() !== this.rustEditor.document.uri.toString())
104+
if (!this.rustEditor || doc.uri.toString() !== this.rustEditor.document.uri.toString()) {
105105
return;
106+
}
106107

107108
const astEditor = this.findAstTextEditor();
108109
if (!astEditor) return;

editors/code/src/snippets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) {
1111
}
1212
for (const [uri, edits] of edit.entries()) {
1313
const editor = await editorFromUri(uri);
14-
if (editor)
14+
if (editor) {
1515
await editor.edit((builder) => {
1616
for (const indel of edits) {
1717
assert(
@@ -21,6 +21,7 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) {
2121
builder.replace(indel.range, indel.newText);
2222
}
2323
});
24+
}
2425
}
2526
}
2627

0 commit comments

Comments
 (0)