[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/csharp-mode 4516a18 223/459: Fix indentation of generic
From: |
ELPA Syncer |
Subject: |
[elpa] externals/csharp-mode 4516a18 223/459: Fix indentation of generic type-initializers. |
Date: |
Sun, 22 Aug 2021 13:59:31 -0400 (EDT) |
branch: externals/csharp-mode
commit 4516a18c0dd1797a2d1eb2ae3069c0e16efa14a7
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Fix indentation of generic type-initializers.
This commit should address
https://github.com/josteink/csharp-mode/issues/95.
---
csharp-mode.el | 31 ++++++++++++++++++++-----------
test-files/indentation-tests.cs | 30 ++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/csharp-mode.el b/csharp-mode.el
index ae1e649..1d97d16 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -412,6 +412,12 @@ Most other csharp functions are not instrumented.
;; constants used in this module
;; ==================================================================
+ (defconst csharp-type-initializer-statement-re
+ (concat
+ "\\<new[ \t\n\r\f\v]+"
+ "\\([[:alpha:]_][[:alnum:]_<>\\.]*\\)")
+ "Regexp that captures a type-initializer statement in C#")
+
(defconst csharp-enum-decl-re
(concat
"\\<enum[ \t\n\r\f\v]+"
@@ -423,8 +429,7 @@ Most other csharp functions are not instrumented.
(list "sbyte" "byte" "short" "ushort" "int" "uint" "long" "ulong"))
"\\)"
"\\)?")
- "Regex that captures an enum declaration in C#"
- )
+ "Regex that captures an enum declaration in C#")
;; ==================================================================
@@ -2596,16 +2601,20 @@ are the string substitutions (see `format')."
(c-safe (c-forward-sexp -1))
(looking-at c-brace-list-key))
- ;; dinoch Thu, 22 Apr 2010 18:20
- ;; ============================================
- ;; looking enum Foo : int
- ;; means this is a brace list, so, return nil,
- ;; implying NOT looking-at-inexpr-block
-
(and (c-major-mode-is 'csharp-mode)
- (progn
- (c-safe (c-forward-sexp -1))
- (looking-at csharp-enum-decl-re))))
+ (or
+ ;; dinoch Thu, 22 Apr 2010 18:20
+ ;; ============================================
+ ;; looking enum Foo : int
+ ;; means this is a brace list, so, return nil,
+ ;; implying NOT looking-at-inexpr-block
+ (progn
+ (c-safe (c-forward-sexp -1))
+ (looking-at csharp-enum-decl-re))
+
+ ;; no need to forward when looking here, because
enum
+ ;; check already did it!
+ (looking-at
csharp-type-initializer-statement-re))))
(setq bracepos (c-down-list-forward (point)))
(not (c-crosses-statement-barrier-p (point)
diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs
index 32a93c8..96b17c3 100644
--- a/test-files/indentation-tests.cs
+++ b/test-files/indentation-tests.cs
@@ -48,6 +48,36 @@ namespace Boo
with = new prop(),
};
+ // test-cases for type initializer indetation issue:
+ // https://github.com/josteink/csharp-mode/issues/95
+ var x_gen = new Foo<bar>
+ {
+ a,
+ b,
+ c
+ };
+
+ return new Foo<bar>
+ {
+ a,
+ b,
+ c
+ };
+
+ yield return new Foo<bar>
+ {
+ a,
+ b,
+ c
+ };
+
+ new Foo<Bar>
+ {
+ a,
+ b,
+ c
+ };
+
var array1 = new ArrayList
{
1, 2, 3, 4, 5
- [elpa] externals/csharp-mode 803a362 203/459: Move log functions back down where they were., (continued)
- [elpa] externals/csharp-mode 803a362 203/459: Move log functions back down where they were., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 8a9ab5a 204/459: imenu: Add test-cases for generic methods., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode b56c250 205/459: Add fontification tests for generic methods., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode f83e2e3 207/459: Fix indentation of generic type-initializers., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 81cf94d 214/459: Update test-data., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode bd42802 216/459: Indentation fix (#88), ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 0c4edfd 217/459: Hopefully fix this CI-snafu for now., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6ccf2cf 219/459: Apply syntax propertize function silently, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6c0a0d6 220/459: Bump version. Update changelog., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode b87332e 222/459: Update documentation for Emacs 25., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 4516a18 223/459: Fix indentation of generic type-initializers.,
ELPA Syncer <=
- [elpa] externals/csharp-mode ed7c30c 224/459: WIP: Fix checkdoc- and package-lint errors, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode bbd2888 232/459: Merge branch 'mattiasb-fix-warnings', ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode bc6a419 237/459: Update changelog., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 8ab3cc8 239/459: Dirty hack to force type-initializer indentation., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode d39d9ac 241/459: Revert "Make csharp-mode-map inherit from prog-mode-map", ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 0027f9c 246/459: Issue #112: Allow whitespace after the `#` in a directive., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode bd54e4d 250/459: Add csharp group definition, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 331b45d 251/459: Try fix/update CI-settings, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 85ae15d 252/459: Hacky formatting trick to make codedoc work with Omnisharp defaults, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 461cd87 254/459: Fix compilation error on Emacs 26., ELPA Syncer, 2021/08/22