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.

languages: Fix detents case line after typing `:` in Python (#34017)

Smit Barmase38febed02d93
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs
index 05280de02b6..aea84de9b02 100644
--- a/crates/editor/src/editor_tests.rs
+++ b/crates/editor/src/editor_tests.rs
@@ -22348,6 +22348,19 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) {
def f() -> list[str]:
aˇ
"});
+
+ // test does not outdent on typing : after case keyword
+ cx.set_state(indoc! {"
+ match 1:
+ caseˇ
+ "});
+ cx.update_editor(|editor, window, cx| {
+ editor.handle_input(":", window, cx);
+ });
+ cx.assert_editor_state(indoc! {"
+ match 1:
+ case:ˇ
+ "});
}
#[gpui::test]
diff --git a/crates/languages/src/python/config.toml b/crates/languages/src/python/config.toml
index 6d83d3f3dec..8728dfeaf13 100644
--- a/crates/languages/src/python/config.toml
+++ b/crates/languages/src/python/config.toml
@@ -34,5 +34,4 @@ decrease_indent_patterns = [
{ pattern = "^\\s*else\\b.*:", valid_after = ["if", "elif", "for", "while", "except"] },
{ pattern = "^\\s*except\\b.*:", valid_after = ["try", "except"] },
{ pattern = "^\\s*finally\\b.*:", valid_after = ["try", "except", "else"] },
- { pattern = "^\\s*case\\b.*:", valid_after = ["match", "case"] }
]
diff --git a/crates/languages/src/python/indents.scm b/crates/languages/src/python/indents.scm
index 617aa706d31..3d4c1cc9c42 100644
--- a/crates/languages/src/python/indents.scm
+++ b/crates/languages/src/python/indents.scm
@@ -14,4 +14,4 @@
(else_clause) @start.else
(except_clause) @start.except
(finally_clause) @start.finally
-(case_pattern) @start.case
+(case_clause) @start.case