GNU bug report logs - #47678
27.1; `completion-boundaries` assertion failure for file

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Fri, 9 Apr 2021 20:36:02 UTC

Severity: normal

Found in version 27.1

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 47678 <at> debbugs.gnu.org
Subject: bug#47678: 27.1; `completion-boundaries` assertion failure for file
Date: Mon, 12 Apr 2021 19:28:00 -0400
> 2. Press "C-x C-f"
> 3. Enter the path "~//"
> 4. Move the point between the slashes, "~/|/"
> 5. Press "C-."

Thanks!
[ It would have helped to say what happens for you there.  ]

> The function `test-boundaries' should determine the completion
> boundaries correctly. I assume that the function `completion-boundaries'
> should never fail with an error.

[ From this I can guess that you maybe got some kind of error?
  Including a backtrace or the text of the error or some
  description of the error would have been helpful.  ]

I installed the patch below, which seems to fix the immediate problem
I managed to reproduce, but it might lead to further problems down
the road.


        Stefan


diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5f594679ca..c900b0d7ce 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -488,8 +488,17 @@ completion-table-with-quoting
              (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.





This bug report was last modified 4 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.