File tree Expand file tree Collapse file tree 1 file changed +31
-13
lines changed Expand file tree Collapse file tree 1 file changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -930,19 +930,37 @@ to point."
930930 " Prepare :type-at command to be send to haskell process.
931931POS is a cons cell containing min and max positions, i.e. target
932932expression bounds."
933- (replace-regexp-in-string
934- " \n $"
935- " "
936- (format " :type-at %s %d %d %d %d %s "
937- (buffer-file-name )
938- (progn (goto-char (car pos))
939- (line-number-at-pos ))
940- (1+ (current-column ))
941- (progn (goto-char (cdr pos))
942- (line-number-at-pos ))
943- (1+ (current-column ))
944- (buffer-substring-no-properties (car pos)
945- (cdr pos)))))
933+ (save-excursion
934+ (let ((start-p (car pos))
935+ (end-p (cdr pos))
936+ start-l
937+ start-c
938+ end-l
939+ end-c
940+ value)
941+ (goto-char start-p)
942+ (setq start-l (line-number-at-pos ))
943+ (setq start-c (1+ (current-column )))
944+ (goto-char end-p)
945+ (setq end-l (line-number-at-pos ))
946+ (setq end-c (1+ (current-column )))
947+ (setq value (buffer-substring-no-properties start-p end-p))
948+ ; ; supress multiline expressions
949+ (let ((lines (split-string value " \n " t )))
950+ (when (and (cdr lines)
951+ (stringp (car lines)))
952+ (setq value (format " [ %s … ] " (car lines)))))
953+ (replace-regexp-in-string
954+ " \n $"
955+ " "
956+ (format " :type-at %s %d %d %d %d %s "
957+ (buffer-file-name )
958+ start-l
959+ start-c
960+ end-l
961+ end-c
962+ value)))))
963+
946964
947965(defun haskell-utils-insert-type-signature (signature )
948966 " Insert type signature.
You can’t perform that action at this time.
0 commit comments