vm / vm-minibuf.el

Diff from to


 	(point-min (if (fboundp 'minibuffer-prompt-end)
+	(case-fold-search completion-ignore-case)
 	trimmed-c-list c-list beg end diff word word-prefix-regexp completion)
     ;; find the beginning and end of the word we're trying to complete
     (if (or (eobp) (memq (following-char) '(?\t ?\n ?\ )))
       (setq diff (- (length completion) (length word)))
        ;; We have some completion chars.  Insert them.
-       ((> diff 0)
+       ((or (> diff 0)
+	    (and (zerop diff) (not (string-equal completion word))))
 	(goto-char end)
-	(insert (substring completion (- diff)))
+	(delete-char (- (length word)))
+	(insert completion)
 	(if (and vm-completion-auto-space
 		 (null (cdr trimmed-c-list)))
 	    (insert " ")))