summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/layouter.nim3
-rw-r--r--nimpretty/tests/exhaustive.nim21
-rw-r--r--nimpretty/tests/expected/exhaustive.nim23
3 files changed, 46 insertions, 1 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim
index 2477458f1..f5d3084dc 100644
--- a/compiler/layouter.nim
+++ b/compiler/layouter.nim
@@ -452,6 +452,9 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
       if tok.tokType in openPars and tok.indent > em.indentStack[^1]:
         while em.indentStack[^1] < tok.indent:
           em.indentStack.add(em.indentStack[^1] + em.indWidth)
+      while em.indentStack[^1] > tok.indent:
+        discard em.indentStack.pop()
+
       # aka: we are in an expression context:
       let alignment = max(tok.indent - em.indentStack[^1], 0)
       em.indentLevel = alignment + em.indentStack.high * em.indWidth
diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim
index d61820f7a..2ba885d9a 100644
--- a/nimpretty/tests/exhaustive.nim
+++ b/nimpretty/tests/exhaustive.nim
@@ -822,3 +822,24 @@ proc f =
   # doesn't break the code, but leaving indentation as is would be nice.
   let x = if true: callingProcWhatever()
           else: callingADifferentProc()
+
+
+type
+  EventKind = enum
+    Stop, StopSuccess, StopError,
+    SymbolChange, TextChange,
+
+  SpinnyEvent = tuple
+    kind: EventKind
+    payload: string
+
+
+type
+  EventKind2 = enum
+    Stop2, StopSuccess2, StopError2,
+    SymbolChange2, TextChange2,
+
+type
+  SpinnyEvent2 = tuple
+    kind: EventKind
+    payload: string
diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim
index e120cf019..cfe9a43fa 100644
--- a/nimpretty/tests/expected/exhaustive.nim
+++ b/nimpretty/tests/expected/exhaustive.nim
@@ -812,7 +812,7 @@ let foo = if cond:
 
 let a =
   [[aaadsfas, bbb],
-    [ccc, ddd]]
+   [ccc, ddd]]
 
 let b = [
   [aaa, bbb],
@@ -835,3 +835,24 @@ proc f =
   # doesn't break the code, but leaving indentation as is would be nice.
   let x = if true: callingProcWhatever()
           else: callingADifferentProc()
+
+
+type
+  EventKind = enum
+    Stop, StopSuccess, StopError,
+    SymbolChange, TextChange,
+
+  SpinnyEvent = tuple
+    kind: EventKind
+    payload: string
+
+
+type
+  EventKind2 = enum
+    Stop2, StopSuccess2, StopError2,
+    SymbolChange2, TextChange2,
+
+type
+  SpinnyEvent2 = tuple
+    kind: EventKind
+    payload: string