Skip to content

Commit 13fc56c

Browse files
authored
Indent on async for and async with (#8938)
1 parent 83f0361 commit 13fc56c

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

news/1 Enhancements/7344.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Automatically indent following `async for` and `async with` statements.

src/client/language/languageConfiguration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ export function getLanguageConfiguration(): LanguageConfiguration {
5454
async \\s+ def |
5555
except |
5656
for |
57+
async \\s+ for |
5758
if |
5859
elif |
5960
while |
60-
with
61+
with |
62+
async \\s+ with
6163
)
6264
\\b .*
6365
) |

src/test/language/languageConfiguration.unit.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const NEEDS_INDENT = [
1919
];
2020
const INDENT_ON_ENTER = [ // block-beginning statements
2121
/^async\s+def\b/,
22+
/^async\s+for\b/,
23+
/^async\s+with\b/,
2224
/^class\b/,
2325
/^def\b/,
2426
/^with\b/,
@@ -142,6 +144,9 @@ suite('Language Configuration', () => {
142144
'async def test(self):',
143145
'async def :',
144146
'async :',
147+
'async for spam in bacon:',
148+
'async with context:',
149+
'async with context in manager:',
145150
'class Test:',
146151
'class Test(object):',
147152
'class :',

0 commit comments

Comments
 (0)