Skip to content

Commit 7430512

Browse files
committed
Merge pull request #1165 from haskell/revert-1121-gman/fix-1109
Revert "Remove suggested imports completely"
2 parents 1e86061 + b9df600 commit 7430512

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

haskell-interactive-mode.el

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ SESSION in specified FILE to remove IMPORT on given LINE."
584584
(cl-case (read-event
585585
(propertize (format "%sThe import line `%s' is redundant. Remove? (y, n, c: comment out) "
586586
(if (not first)
587-
"Please answer y, n or c: "
587+
"Please answer n, y or c: "
588588
"")
589589
import)
590590
'face
@@ -594,38 +594,21 @@ SESSION in specified FILE to remove IMPORT on given LINE."
594594
(save-excursion
595595
(goto-char (point-min))
596596
(forward-line (1- line))
597-
(let ((bounds (haskell-interactive-mode--import-statement-bounds)))
598-
(delete-region (car bounds) (cdr bounds))
599-
(kill-line 1))))
597+
(goto-char (line-beginning-position))
598+
(delete-region (line-beginning-position)
599+
(line-end-position))))
600600
(?n
601601
(message "Ignoring redundant import %s" import))
602602
(?c
603603
(haskell-process-find-file session file)
604604
(save-excursion
605605
(goto-char (point-min))
606606
(forward-line (1- line))
607-
(let ((bounds (haskell-interactive-mode--import-statement-bounds)))
608-
(comment-region (car bounds) (cdr bounds))))))
607+
(goto-char (line-beginning-position))
608+
(insert "-- "))))
609609
;; unwind
610610
(haskell-mode-toggle-interactive-prompt-state t))))
611611

612-
(defun haskell-interactive-mode--import-statement-bounds ()
613-
"For internal use in `haskell-process-suggest-remove-import'.
614-
This function supposed to be called having point placed on first
615-
line of import statement, if this is a case it search import
616-
statement bounds relying on layout and returns them as cons cell;
617-
otherwise returns nil."
618-
(save-excursion
619-
(goto-char (line-beginning-position))
620-
(when (looking-at-p (regexp-quote "import"))
621-
(let ((a (point))
622-
(z (line-end-position)))
623-
(forward-line 1)
624-
(while (looking-at-p (rx (and not-newline (1+ whitespace))))
625-
(setq z (line-end-position))
626-
(forward-line 1))
627-
(cons a z)))))
628-
629612
(defun haskell-process-find-file (session file)
630613
"Find the given file in the project."
631614
(find-file (cond ((file-exists-p (concat (haskell-session-current-dir session) "/" file))

tests/interactive-haskell-mode-tests.el

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@
3232
(require 'ert)
3333
(require 'haskell-interactive-mode)
3434

35+
(defun should-match (str)
36+
(should (eq 0 (string-match-p haskell-interactive-mode-error-regexp str))))
37+
3538
(ert-deftest haskell-interactive-error-regexp-test ()
3639
"Tests the regexp `haskell-interactive-mode-error-regexp'"
3740
(should (eq 0 (string-match-p haskell-interactive-mode-error-regexp
3841
"/home/user/Test.hs:24:30:")))
3942
(should (eq 0 (string-match-p haskell-interactive-mode-error-regexp
4043
"Test.hs:5:18:")))
41-
(should (eq 0 (string-match-p
42-
haskell-interactive-mode-error-regexp
43-
"Test.hs:7:6: Not in scope: type constructor or class ‘Ty’")))
44+
(should (eq 0 (string-match-p haskell-interactive-mode-error-regexp
45+
"Test.hs:7:6: Not in scope: type constructor or class ‘Ty’")))
4446
(should (eq 0 (string-match-p haskell-interactive-mode-error-regexp
4547
"Test.hs:9:5: Not in scope: ‘c’")))
4648
(should (eq nil (string-match-p haskell-interactive-mode-error-regexp
4749
;; leading space
4850
" Test.hs:8:9:")))
4951
)
50-
51-
(provide 'interactive-haskell-mode-tests)
52-
;;; interactive-haskell-mode-tests.el ends here

0 commit comments

Comments
 (0)