From c91f1b9b59b562c6573b313e9c0902740335c9b7 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 9 Oct 2015 00:24:39 +0200 Subject: [PATCH 1/2] Navigate back to a real top level declaration --- haskell-indentation.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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))))) From ce9f1df2012f2a01bdf0a21439a37763001991b8 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Fri, 9 Oct 2015 00:25:12 +0200 Subject: [PATCH 2/2] Mark test as good enough --- tests/haskell-indentation-tests.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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