]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/minibuffer.el (completion-table-with-quoting): Fix bug#47678
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 12 Apr 2021 23:23:45 +0000 (19:23 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 12 Apr 2021 23:23:57 +0000 (19:23 -0400)
lisp/minibuffer.el

index 5f594679ca353ee3860ff41af8639f69c1e823b0..c900b0d7ce6fdc0f5b0f8491cd58a31dbe43d8fd 100644 (file)
@@ -488,8 +488,17 @@ for use at QPOS."
              (qsuffix (cdr action))
              (ufull (if (zerop (length qsuffix)) ustring
                       (funcall unquote (concat string qsuffix))))
-             (_ (cl-assert (string-prefix-p ustring ufull)))
-             (usuffix (substring ufull (length ustring)))
+             ;; If (not (string-prefix-p ustring ufull)) we have a problem:
+             ;; the unquoting the qfull gives something "unrelated" to ustring.
+             ;; E.g. "~/" and "/" where "~//" gets unquoted to just "/" (see
+             ;; bug#47678).
+             ;; In that case we can't even tell if we're right before the
+             ;; "/" or right after it (aka if this "/" is from qstring or
+             ;; from qsuffix), which which usuffix to use is very unclear.
+             (usuffix (if (string-prefix-p ustring ufull)
+                          (substring ufull (length ustring))
+                        ;; FIXME: Maybe "" is preferable/safer?
+                        qsuffix))
              (boundaries (completion-boundaries ustring table pred usuffix))
              (qlboundary (car (funcall requote (car boundaries) string)))
              (qrboundary (if (zerop (cdr boundaries)) 0 ;Common case.