File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -425,6 +425,44 @@ fn foo()
425
425
"
426
426
))
427
427
428
+ (ert-deftest indent-match ()
429
+ (test-indent
430
+ "
431
+ fn foo() {
432
+ match blah {
433
+ Pattern => stuff(),
434
+ _ => whatever
435
+ }
436
+ }
437
+ "
438
+ ))
439
+
440
+ (ert-deftest indent-match-multiline-pattern ()
441
+ (test-indent
442
+ "
443
+ fn foo() {
444
+ match blah {
445
+ Pattern |
446
+ Pattern2 => {
447
+ hello()
448
+ },
449
+ _ => whatever
450
+ }
451
+ }
452
+ "
453
+ ))
454
+
455
+ ; ; Make sure that in effort to cover match patterns we don't mistreat || or expressions
456
+ (ert-deftest indent-nonmatch-or-expression ()
457
+ (test-indent
458
+ "
459
+ fn foo() {
460
+ let x = foo() ||
461
+ bar();
462
+ }
463
+ "
464
+ ))
465
+
428
466
(setq rust-test-motion-string
429
467
"
430
468
fn fn1(arg: int) -> bool {
Original file line number Diff line number Diff line change 85
85
; ; - { means indent to either nesting-level * rust-indent-offset,
86
86
; ; or one further indent from that if either current line
87
87
; ; begins with 'else', or previous line didn't end in
88
- ; ; semi, comma or brace (other than whitespace and line
88
+ ; ; semi, comma, brace or single pipe (other than whitespace and line
89
89
; ; comments) , and wasn't an attribute. But if we have
90
90
; ; something after the open brace and ending with a comma,
91
91
; ; treat it as fields and align them. PHEW.
105
105
(beginning-of-line )
106
106
(rust-rewind-irrelevant)
107
107
(end-of-line )
108
- (if (looking-back
109
- " [[,;{}(][[:space:]]*\\ (?://.*\\ )?" )
108
+ (if (looking-back " \\ (?:[(,:;?[{}]\\ |[^|]|\\ )[[:space:]]*\\ (?://.*\\ )?" )
110
109
(* rust-indent-offset level)
111
110
(back-to-indentation )
112
111
(if (looking-at " #" )
You can’t perform that action at this time.
0 commit comments