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

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

[elpa] externals/csharp-mode 85d36e1 280/459: Fix lambda indentation #10


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 85d36e1 280/459: Fix lambda indentation #105
Date: Sun, 22 Aug 2021 13:59:44 -0400 (EDT)

branch: externals/csharp-mode
commit 85d36e12db854c88202163f912140f9cd5b82a35
Author: Krzysztof Witkowski <krzysztof.witkowski@gmail.com>
Commit: Krzysztof Witkowski <krzysztof.witkowski@gmail.com>

    Fix lambda indentation #105
---
 csharp-mode.el                  | 12 ++++++++++--
 test-files/indentation-tests.cs | 20 ++++++++++++++------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index 85c7745..0fea1d1 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -556,6 +556,10 @@ to work properly with code that includes attributes."
        (t nil))
       )))
 
+(defun csharp--at-lambda-header ()
+  "Determines if there is lambda header at point"
+  (or (looking-at "([[:alnum:][:space:]_,]*)[ \t\n]*=>[ \t\n]*{")
+      (looking-at "[[:alnum:]_]+[ \t\n]*=>[ \t\n]*{")))
 
 ;; ==================================================================
 ;; end of csharp-mode utility and feature defuns
@@ -2549,7 +2553,8 @@ are the string substitutions (see `format')."
                          (> (point) closest-lim))
                   (not (bobp))
                   (progn (backward-char)
-                         (looking-at "[\]\).]\\|\w\\|\\s_"))
+                         (or (looking-at "[\]\).]\\|\w\\|\\s_")
+                             (looking-at ">")))
                   (c-safe (forward-char)
                           (goto-char (scan-sexps (point) -1))))
 
@@ -2612,7 +2617,10 @@ are the string substitutions (see `format')."
                             'maybe)
                       (setq passed-paren (char-after))
                       'maybe)
-                  'maybe))))
+                  'maybe)
+
+                (if (csharp--at-lambda-header)
+                    (cons 'inexpr (point))))))
 
       (if (eq res 'maybe)
           (when (and c-recognize-paren-inexpr-blocks
diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs
index 4c32a5a..8d91f78 100644
--- a/test-files/indentation-tests.cs
+++ b/test-files/indentation-tests.cs
@@ -162,21 +162,29 @@ namespace Boo
 
             /* Callback indentation test. */
             SomeFunction(() => {
-                    // empty.
-                });
+                System
+                    .Console
+                    .WriteLine("boo");
+            });
 
             SomeFunction(() =>
             {
-                // empty.
+                System
+                    .Console
+                    .WriteLine("boo");
             });
 
             SomeFunction((withParam) => {
-                    // empty.
-                });
+                System
+                    .Console
+                    .WriteLine("boo");
+            });
 
             SomeFunction((withParam) =>
             {
-                // empty.
+                System
+                    .Console
+                    .WriteLine("boo");
             });
         }
 



reply via email to

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