branch: elpa/swift-mode commit e539ba615ec041d24ebbc2abfc27b5e88c113ecd Author: ap4y <l...@pisem.net> Commit: ap4y <l...@pisem.net>
Improve support for the multi-line case statements --- swift-mode.el | 4 ++-- test/indentation-tests.el | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index 04be414..ae06f79 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -260,7 +260,7 @@ (t (let ((tok (smie-default-forward-token))) (cond ((equal tok "case") - (if (looking-at ".+\\(where.*[,]\\|:\\)") + (if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)") "case" "ecase")) (t tok)))) @@ -303,7 +303,7 @@ (t (let ((tok (smie-default-backward-token))) (cond ((equal tok "case") - (if (looking-at ".+\\(where.*[,]\\|:\\)") + (if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)") "case" "ecase")) (t tok)))) diff --git a/test/indentation-tests.el b/test/indentation-tests.el index bbea69c..a395291 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -264,6 +264,35 @@ switch true { } ") +(check-indentation indents-case-statements-to-same-level-as-enclosing-switch/5 + " +switch { + |case foo, + bar, buz: + foo +} +" " +switch { +|case foo, + bar, buz: + foo +} +") + +(check-indentation indents-case-statements-to-same-level-as-enclosing-switch/6 + " +switch { + |case + foo, bar, buz: + foo +} +" " +switch { +|case + foo, bar, buz: + foo +} +") (check-indentation indents-case-statement-bodies/1 "