Skip to content

Commit ae644e9

Browse files
Emacs completion: Include module prefix in completion candidates
Fixes a mismatch of the completion START position in the Emacs buffer and the candidatates that didn't include the expected module-prefix. Fixes #455
1 parent 3322ada commit ae644e9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/top/utop.el

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,10 @@ it is started."
604604
(dolist (prefix utop-completion-prefixes)
605605
;; We need to handle specially prefixes like "List.m" as
606606
;; the responses from utop don't include the module prefix.
607-
(let ((prefix (if (string-match-p "\\." prefix)
608-
(cadr (split-string prefix "\\."))
609-
prefix)))
610-
(when (string-prefix-p prefix argument)
611-
(push argument utop-completion)
612-
(throw 'done t))))))
607+
(if-let* ((pos (string-match "[^.]*$" prefix))
608+
((string-prefix-p (substring prefix pos) argument)))
609+
(push (concat (substring prefix 0 pos) argument) utop-completion)
610+
(throw 'done t)))))
613611
;; End of completion
614612
("completion-stop"
615613
(utop-set-state 'edit)

0 commit comments

Comments
 (0)