feat(python): add match-case indents

This commit is contained in:
Pham Huy Hoang
2023-03-25 09:29:32 +09:00
committed by Amaan Qureshi
parent a072d923c7
commit 1ffa019856
3 changed files with 23 additions and 0 deletions

View File

@@ -44,6 +44,10 @@
(#set! indent.immediate 1))
((with_statement) @indent.begin
(#set! indent.immediate 1))
((match_statement) @indent.begin
(#set! indent.immediate 1))
((case_clause) @indent.begin
(#set! indent.immediate 1))
(if_statement
condition: (parenthesized_expression) @indent.align

View File

@@ -0,0 +1,15 @@
a = 0
def test_match_case():
match a:
case 1:
return
def test_match():
match a:
def test_case():
match a:
case b:

View File

@@ -84,6 +84,10 @@ describe("indent Python:", function()
run:new_line("line_after_indent.py", { on_line = 49, text = "x", indent = 0 })
run:new_line("line_after_indent.py", { on_line = 55, text = "x", indent = 4 })
run:new_line("line_after_indent.py", { on_line = 63, text = "x", indent = 4 })
run:new_line("match_case.py", { on_line = 4, text = "pass", indent = 8 })
run:new_line("match_case.py", { on_line = 5, text = "pass", indent = 12 })
run:new_line("match_case.py", { on_line = 10, text = "pass", indent = 8 })
run:new_line("match_case.py", { on_line = 15, text = "pass", indent = 12 })
for _, line in ipairs { 2, 5, 8, 11, 16, 21, 24, 27, 34, 39 } do
run:new_line("return_dedent.py", { on_line = line, text = "x", indent = 0 })