Skip to content

Commit ebd67a1

Browse files
committed
Correctly indent nested generic object initializers
This properly closes #85
1 parent f9122bb commit ebd67a1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

csharp-mode.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,11 @@ to work properly with code that includes attributes.
484484
;; typename
485485
"\\(?:[A-Za-z_][[:alnum:]]*\\.\\)*"
486486
"[A-Za-z_][[:alnum:]]*"
487-
;; optional generic constraint
488-
"\\(?:<\\(?:[[:alpha:]][[:alnum:]]*\\)\\(?:[, ]+[[:alpha:]][[:alnum:]]*\\)*>\\)?"
487+
;; simplified generic constraint.
488+
;; handles generic sub-types.
489+
;; { is optional because otherwise initializers with
490+
;; bracket on same line will indent wrongly.
491+
"\\(?:<[[:alnum:], <>]+>[ \t\n\f\v\r]*{?\\)?"
489492
;; optional array-specifier
490493
"\\(?:\\[\\]\\)?"
491494
;; spacing

test-files/indentation-tests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public void Test()
6969
{ 2, "false" },
7070
};
7171

72+
var map3 = new Dictionary<string,Func<int, bool>>
73+
{
74+
{ "IsZero", (int i) => i == 0 }
75+
};
76+
7277
using (test)
7378
{
7479
System.Console.WriteLine("boo");

0 commit comments

Comments
 (0)