Skip to content

Fix indent for do inside a list #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions haskell-indentation.el
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ Skip the keyword or parenthesis." ; FIXME: better description needed
(starter-indent (min starter-column current-indent))
(left-indent
(if end
(+ current-indent haskell-indentation-starter-offset)
(+ starter-indent haskell-indentation-starter-offset)
left-indent)))
(funcall parser)
(cond ((eq current-token 'end-tokens)
Expand Down Expand Up @@ -926,7 +926,9 @@ l = [ 1
(throw 'return nil))
(separator-column ; on the beginning of the line
(setq current-indent (current-column))
(setq starter-indent separator-column)))))
(setq starter-indent separator-column)
(setq left-indent
(+ starter-indent haskell-indentation-starter-offset))))))

(defun haskell-indentation-implicit-layout-list (parser)
"An implicit layout list, elements are parsed with PARSER.
Expand Down Expand Up @@ -1119,7 +1121,6 @@ line."
(when (= (current-column) (haskell-indentation-current-indentation))
;; on a new line
(setq current-indent (current-column))
(setq left-indent (current-column))
(setq parse-line-number (+ parse-line-number 1)))
(cond ((and implicit-layout-active
(> layout-indent (current-column)))
Expand Down
31 changes: 29 additions & 2 deletions tests/haskell-indentation-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ macro quotes them for you."
function = Record
{ field = 123 }"
((1 0) 0)
((2 0) 0 11)
((3 0) 0 7))
((2 0) 0 11))

(hindent-test "2 Handle underscore in identifiers""
function = do
Expand Down Expand Up @@ -719,4 +718,32 @@ a = ( 1
((2 0) 4)
((2 2) 6))

(hindent-test "41 open do inside a list" "
x = asum [ withX $ do
return ()
]
"
((2 0) 13))

(hindent-test "42 open do inside a list second element" "
x = asum [ mzero
, withX $ do
return ()
]
"
((3 0) 13))

(hindent-test "43 open do inside a list second element, reset alignment" "
x = asum [ mzero
, withX $ do
return ()
]
"
((3 0) 17))

(hindent-test "44 expression continues, reset alignment" "
function = abc
def
xyz"
((3 0) 0 7))
;;; haskell-indentation-tests.el ends here