Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

python: Fix incorrect indenting of `except`, `finally`, `else`, and `elif` control flow (#27428)

Ben Kunklee273de5490c6
diff --git a/crates/languages/src/python/indents.scm b/crates/languages/src/python/indents.scm
index 112b414aa45..134b648cb6a 100644
--- a/crates/languages/src/python/indents.scm
+++ b/crates/languages/src/python/indents.scm
@@ -1,3 +1,18 @@
(_ "[" "]" @end) @indent
(_ "{" "}" @end) @indent
(_ "(" ")" @end) @indent
+
+(try_statement
+ body: (_) @start
+ [(except_clause) (finally_clause)] @end
+ ) @indent
+
+(if_statement
+ consequence: (_) @start
+ alternative: (_) @end
+ ) @indent
+
+(_
+ alternative: (elif_clause) @start
+ alternative: (_) @end
+ ) @indent