Skip to content

Commit 3434af6

Browse files
committed
Merge pull request #921 from gracjan/pr-navigate-to-top-level
Navigate to top level declaration in indenatation
2 parents 553ff12 + ce9f1df commit 3434af6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

haskell-indentation.el

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,18 @@ the current buffer."
603603
(while (not (bobp))
604604
(forward-comment (- (buffer-size)))
605605
(beginning-of-line)
606-
(let ((ps (nth 8 (syntax-ppss))))
607-
(when ps ;; inside comment or string
608-
(goto-char ps)))
609-
(when (= 0 (haskell-indentation-current-indentation))
610-
(throw 'return nil))))
606+
(let* ((ps (syntax-ppss))
607+
(start-of-comment-or-string (nth 8 ps))
608+
(start-of-list-expression (nth 1 ps)))
609+
(cond
610+
(start-of-comment-or-string
611+
;; inside comment or string
612+
(goto-char start-of-comment-or-string))
613+
(start-of-list-expression
614+
;; inside a parenthesized expression
615+
(goto-char start-of-list-expression))
616+
((= 0 (haskell-indentation-current-indentation))
617+
(throw 'return nil))))))
611618
(beginning-of-line)
612619
(when (bobp)
613620
(forward-comment (buffer-size)))))

tests/haskell-indentation-tests.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,14 @@ foo = ()
625625
((4 0) 0))
626626

627627

628-
(hindent-test "34* beginning of line inside parentheses" "
628+
(hindent-test "34 beginning of line inside parentheses" "
629629
data T = T {
630630
foo :: String
631631
, bar :: String
632632
}
633633
634634
"
635-
((5 0) 0))
635+
;; set of answers isn't best but it is not a bug
636+
;; should be just 0
637+
((5 0) 0 9))
636638
;;; haskell-indentation-tests.el ends here

0 commit comments

Comments
 (0)