branch: externals/csharp-mode commit bd4280255ff4752c215468f6b19a002687f600c8 Author: Jostein Kjønigsen <jost...@kjonigsen.net> Commit: GitHub <nore...@github.com>
Indentation fix (#88) * Add test-case for switch/case indentation-bug. More info here: https://github.com/josteink/csharp-mode/issues/86 * Allow strings as switch-case values Closes #86 --- csharp-mode.el | 8 ++++++++ test-files/indentation-tests.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/csharp-mode.el b/csharp-mode.el index 1edc9c8..1093892 100644 --- a/csharp-mode.el +++ b/csharp-mode.el @@ -1395,6 +1395,14 @@ This regexp is assumed to not match any non-operator identifier." (c-lang-const c-cpp-matchers))) +;; allow strings as switch-case values by leaving out string +;; delimiters in this definition +(c-lang-defconst c-nonlabel-token-key + csharp (c-make-keywords-re t + (cl-set-difference (c-lang-const c-keywords) + (append (c-lang-const c-label-kwds) + (c-lang-const c-protection-kwds)) + :test 'string-equal))) (defconst csharp-font-lock-keywords-1 (c-lang-const c-matchers-1 csharp) "Minimal highlighting for C# mode.") diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs index 8b09dcf..32a93c8 100644 --- a/test-files/indentation-tests.cs +++ b/test-files/indentation-tests.cs @@ -79,5 +79,31 @@ namespace Boo System.Console.WriteLine("boo"); } } + + public void CaseStamentIndentation() + { + int bar = 0; + switch (foo) + { + case "foo": + bar = 0; + break; + } + switch (bar) + { + case 1: + case 2: + bar = 0; + break; + } + switch (foo) + { + case "foo": + case "bar": + bar = 0; + bar += 1; + break; + } + } } }