emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swift-mode 01a1127 318/496: Fix indentation before "where"


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 01a1127 318/496: Fix indentation before "where"
Date: Sun, 29 Aug 2021 11:33:58 -0400 (EDT)

branch: elpa/swift-mode
commit 01a112754ebb21df12a9b900d595044c5db675fe
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Fix indentation before "where"
---
 swift-mode-indent.el              | 16 +++++++++++-----
 test/swift-files/statements.swift | 30 +++++++++++++++---------------
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index b1bca83..fcdc999 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -311,11 +311,17 @@
       (let ((parent (save-excursion (swift-mode:backward-sexps-until
                                      (append swift-mode:statement-parent-tokens
                                              '("case"))))))
-        (swift-mode:find-and-align-with-parents
-         (append swift-mode:statement-parent-tokens
-                 '(< "case" "catch" "for")
-                 (if (equal (swift-mode:token:text parent) "case") '(\,) '()))
-         swift-mode:multiline-statement-offset)))
+        (if (equal (swift-mode:token:text parent) "case")
+            (progn
+              (goto-char (swift-mode:token:end previous-token))
+              (swift-mode:backward-token-or-list)
+              (swift-mode:calculate-indent-of-expression
+               swift-mode:multiline-statement-offset
+               swift-mode:multiline-statement-offset))
+          (swift-mode:find-and-align-with-parents
+           (append swift-mode:statement-parent-tokens
+                   '(< "case" "catch" "for"))
+           swift-mode:multiline-statement-offset))))
 
      ;; After {
      ((eq previous-type '{)
diff --git a/test/swift-files/statements.swift 
b/test/swift-files/statements.swift
index 3decd4f..adecd27 100644
--- a/test/swift-files/statements.swift
+++ b/test/swift-files/statements.swift
@@ -577,17 +577,17 @@ default:
 switch foo {
 case let
        .P(x)
-         where // swift-mode:test:known-bug
+         where
            foo
              .bar(),
      let
        .Q(x)
-         where // swift-mode:test:known-bug
+         where
            foo
              .bar(),
      let
        .R(x)
-         where // swift-mode:test:known-bug
+         where
            foo
              .bar():
     foo()
@@ -601,17 +601,17 @@ switch foo {
 case
   let
     .P(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let
     .Q(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let
     .R(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar():
     foo()
@@ -625,17 +625,17 @@ switch foo {
 case
   let Foo
     .P(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let Foo
     .Q(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let Foo
     .R(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar():
     foo()
@@ -657,19 +657,19 @@ case
   let
     Foo
     .P(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let
     Foo
     .Q(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let
     Foo
     .R(x)
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar():
     foo()
@@ -683,18 +683,18 @@ switch foo {
 case
   is
     Foo
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   is
     Foo
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar(),
   let Foo
     .Bar
     .Baz
-      where // swift-mode:test:known-bug
+      where
         foo
           .bar():
     foo()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]