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

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

[elpa] externals/csharp-mode ebd67a1 209/459: Correctly indent nested ge


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode ebd67a1 209/459: Correctly indent nested generic object initializers
Date: Sun, 22 Aug 2021 13:59:28 -0400 (EDT)

branch: externals/csharp-mode
commit ebd67a1d2301434ef704c6cd77982808764f463f
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Correctly indent nested generic object initializers
    
    This properly closes https://github.com/josteink/csharp-mode/issues/85
---
 csharp-mode.el                  | 7 +++++--
 test-files/indentation-tests.cs | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index d0ba8dd..cc6cbb0 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -484,8 +484,11 @@ to work properly with code that includes attributes.
                       ;; typename
                       "\\(?:[A-Za-z_][[:alnum:]]*\\.\\)*"
                       "[A-Za-z_][[:alnum:]]*"
-                      ;; optional generic constraint
-                      "\\(?:<\\(?:[[:alpha:]][[:alnum:]]*\\)\\(?:[, 
]+[[:alpha:]][[:alnum:]]*\\)*>\\)?"
+                      ;; simplified generic constraint.
+                      ;; handles generic sub-types.
+                      ;; { is optional because otherwise initializers with
+                      ;; bracket on same line will indent wrongly.
+                      "\\(?:<[[:alnum:], <>]+>[ \t\n\f\v\r]*{?\\)?"
                       ;; optional array-specifier
                       "\\(?:\\[\\]\\)?"
                       ;; spacing
diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs
index 4fa4ff5..8b09dcf 100644
--- a/test-files/indentation-tests.cs
+++ b/test-files/indentation-tests.cs
@@ -69,6 +69,11 @@ namespace Boo
                 { 2, "false" },
             };
 
+            var map3 = new Dictionary<string,Func<int, bool>>
+            {
+                { "IsZero", (int i) => i == 0 }
+            };
+
             using (test)
             {
                 System.Console.WriteLine("boo");



reply via email to

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