branch: externals/csharp-mode
commit 5a3d4a92737d0eb8db5118630f6838243971ddbb
Author: Theodor Thornhill <[email protected]>
Commit: Theodor Thornhill <[email protected]>
More indentation fixes
---
csharp-mode-indent.el | 6 +++++-
csharp-mode.el | 5 +++--
test-files/indentation-tests.cs | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/csharp-mode-indent.el b/csharp-mode-indent.el
index 03ec002..0661032 100644
--- a/csharp-mode-indent.el
+++ b/csharp-mode-indent.el
@@ -37,6 +37,8 @@
'((indent-all . ;; these nodes are always indented
(accessor_declaration
break_statement
+ conditional_expression
+ arrow_expression_clause
"."))
(indent-rest . ;; if parent node is one of these and node is not first →
indent
(
@@ -49,10 +51,12 @@
initializer_expression
expression_statement
declaration_list
+ attribute_argument_list
+ parameter_list
switch_body))
(paren-indent . ;; if parent node is one of these → indent to paren opener
- ())
+ (parenthesized_expression))
(align-char-to . ;; chaining char → node types we move parentwise to find
the first chaining char
())
(aligned-siblings . ;; siblings (nodes with same parent) should be aligned
to the first child
diff --git a/csharp-mode.el b/csharp-mode.el
index 8798974..f6d84d5 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -191,13 +191,14 @@ Key bindings:
"default" "typeof" "try" "catch" "finally" "break"
"foreach" "in" "yield" "get" "set" "when" "as" "out"
"is" "while" "continue" "this" "ref" "goto" "interface"
+ "from" "where" "select"
] @keyword
;; Linq
- (from_clause (identifier) @variable) @keyword
+ (from_clause (identifier) @variable)
(group_clause)
(order_by_clause)
- (select_clause)
+ (select_clause (identifier) @variable)
(query_continuation (identifier) @variable) @keyword
;; String
diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs
index d4833da..837dd54 100644
--- a/test-files/indentation-tests.cs
+++ b/test-files/indentation-tests.cs
@@ -255,3 +255,43 @@ public async Task WriteAsync()
}
}
}
+
+namespace Foo
+{
+ internal T GetThings()
+ {
+ private Thing<int> Values(string key, int[] numbers, bool ignoreCase)
+ {
+ return (from n in numbers
+ where string.Equals("", "")
+ select n);
+ }
+
+ private string GetKey(int number, bool randomCase)
+ {
+ if (randomCase)
+ {
+ bool upper = false
+ return (upper ? "AA" : "aa");
+ }
+ else
+ {
+ return "AA" + Right2Chars(number.ToString());
+ }
+ }
+ }
+}
+
+namespace Foo
+{
+ internal T GetAssemblies()
+ {
+ static string GetRelativePath(string path, Uri baseUri)
+ {
+ var rootedPath = Path.IsPathRooted(path)
+ ? path
+ : x;
+ return rootedPath;
+ }
+ }
+}