diff --git a/haskell-indentation.el b/haskell-indentation.el index d3d76c381..781192255 100644 --- a/haskell-indentation.el +++ b/haskell-indentation.el @@ -603,11 +603,18 @@ the current buffer." (while (not (bobp)) (forward-comment (- (buffer-size))) (beginning-of-line) - (let ((ps (nth 8 (syntax-ppss)))) - (when ps ;; inside comment or string - (goto-char ps))) - (when (= 0 (haskell-indentation-current-indentation)) - (throw 'return nil)))) + (let* ((ps (syntax-ppss)) + (start-of-comment-or-string (nth 8 ps)) + (start-of-list-expression (nth 1 ps))) + (cond + (start-of-comment-or-string + ;; inside comment or string + (goto-char start-of-comment-or-string)) + (start-of-list-expression + ;; inside a parenthesized expression + (goto-char start-of-list-expression)) + ((= 0 (haskell-indentation-current-indentation)) + (throw 'return nil)))))) (beginning-of-line) (when (bobp) (forward-comment (buffer-size))))) diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el index d6d2064e6..5b8ffde2c 100644 --- a/tests/haskell-indentation-tests.el +++ b/tests/haskell-indentation-tests.el @@ -625,12 +625,14 @@ foo = () ((4 0) 0)) -(hindent-test "34* beginning of line inside parentheses" " +(hindent-test "34 beginning of line inside parentheses" " data T = T { foo :: String , bar :: String } " - ((5 0) 0)) + ;; set of answers isn't best but it is not a bug + ;; should be just 0 + ((5 0) 0 9)) ;;; haskell-indentation-tests.el ends here