diff options
| author | Andrei Listochkin <andrei.listochkin@ferrous-systems.com> | 2022-05-17 18:31:51 +0100 |
|---|---|---|
| committer | Andrei Listochkin <andrei.listochkin@ferrous-systems.com> | 2022-05-17 18:31:51 +0100 |
| commit | 00a97272f2fe00c09dd954c21fffb4efebc208af (patch) | |
| tree | ea1e1dc99826158202fa692aa1c43a9d1711c4ad /editors/code/src/snippets.ts | |
| parent | e0df2c9beed4107f66d185452fdbf0aed9271b8d (diff) | |
| download | rust-00a97272f2fe00c09dd954c21fffb4efebc208af.tar.gz rust-00a97272f2fe00c09dd954c21fffb4efebc208af.zip | |
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.
Diffstat (limited to 'editors/code/src/snippets.ts')
| -rw-r--r-- | editors/code/src/snippets.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index 14c2121d08a..299d29c27ee 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -11,7 +11,7 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) { } for (const [uri, edits] of edit.entries()) { const editor = await editorFromUri(uri); - if (editor) + if (editor) { await editor.edit((builder) => { for (const indel of edits) { assert( @@ -21,6 +21,7 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) { builder.replace(indel.range, indel.newText); } }); + } } } |
