Skip to content

Commit 7fc893e

Browse files
authored
Merge pull request #1401 from gracjan/pr-indentation-operators
Operators at the end or beggining of line force continuation
2 parents 6059ea6 + a4946f0 commit 7fc893e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

haskell-indentation.el

+5-1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ and indent when all of the following are true:
388388
;; the token at the current parser point or a pseudo-token (see
389389
;; `haskell-indentation-read-next-token')
390390
(defvar current-token)
391+
(defvar previous-token)
391392
(defvar left-indent) ;; most left possible indentation
392393
(defvar starter-indent) ;; column at a keyword
393394
(defvar current-indent) ;; the most right indentation
@@ -456,6 +457,7 @@ and indent when all of the following are true:
456457
(left-indent haskell-indentation-layout-offset)
457458
(case-fold-search nil)
458459
current-token
460+
previous-token
459461
following-token
460462
possible-indentations
461463
implicit-layout-active)
@@ -1032,7 +1034,8 @@ layout starts."
10321034
(haskell-indentation-read-next-token))
10331035
((eq current-token 'end-tokens)
10341036
(when (or (and
1035-
(not (string= following-token "{"))
1037+
(not (member following-token '("{" operator)))
1038+
(not (member previous-token '(operator)))
10361039
(haskell-indentation-expression-token-p following-token))
10371040
(string= following-token ";")
10381041
(and (equal layout-indent 0)
@@ -1182,6 +1185,7 @@ line."
11821185
(> layout-indent (current-column)))
11831186
(setq current-token 'layout-end))
11841187
(t
1188+
(setq previous-token (haskell-indentation-peek-token))
11851189
(haskell-indentation-skip-token)
11861190
(if (>= (point) indentation-point)
11871191
(progn

tests/haskell-indentation-tests.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ resolve (amount, max) number
284284
(3 2)
285285
(4 0 2 4 20))
286286

287-
(hindent-test "9* Operator last on line""
287+
(hindent-test "9 Operator last on line""
288288
fun = x ++"
289289
(1 0)
290-
(2 6))
290+
(2 2 6))
291291

292-
(hindent-test "10* Operator first on line""
292+
(hindent-test "10 Operator first on line""
293293
fun = x
294294
++ z"
295295
(1 0)

0 commit comments

Comments
 (0)