(or "def" "for" "with")))
symbol-end))
(dedenter (seq symbol-start
- (or "elif" "else" "except" "finally")
+ (or "elif" "else" "except" "finally" "case")
symbol-end))
(block-ender (seq symbol-start
(or
(pairs '(("elif" "elif" "if")
("else" "if" "elif" "except" "for" "while")
("except" "except" "try")
- ("finally" "else" "except" "try")))
+ ("finally" "else" "except" "try")
+ ("case" "case")))
(dedenter (match-string-no-properties 0))
(possible-opening-blocks (cdr (assoc-string dedenter pairs)))
(collected-indentations)
(python-indent-line t)
(should (= (python-indent-calculate-indentation t) 6))))
+(ert-deftest python-indent-dedenters-9 ()
+ "Test de-indentation for the case keyword."
+ (python-tests-with-temp-buffer
+ "
+match a:
+ case 1:
+ print(1)
+ case 2
+"
+ (python-tests-look-at "case 2")
+ (should (eq (car (python-indent-context)) :at-dedenter-block-start))
+ (should (= (python-indent-calculate-indentation) 4))
+ (python-indent-line t)
+ (should (= (python-indent-calculate-indentation t) 4))))
+
(ert-deftest python-indent-inside-string-1 ()
"Test indentation for strings."
(python-tests-with-temp-buffer