branch: externals/csharp-mode commit ebd67a1d2301434ef704c6cd77982808764f463f Author: Jostein Kjønigsen <jost...@kjonigsen.net> Commit: Jostein Kjønigsen <jost...@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");