]> git.eshelyaron.com Git - emacs.git/commitdiff
semantic: Deal with missing prefix when completing symbol
authorEric Ludlam <eric@siege-engine.com>
Mon, 16 Feb 2015 13:38:42 +0000 (08:38 -0500)
committerDavid Engster <deng@randomsample.de>
Fri, 20 Jan 2017 21:54:27 +0000 (22:54 +0100)
* lisp/cedet/semantic/ia.el (semantic-ia-complete-symbol): Protect
 against a nil prefix.
 (semantic-ia-complete-symbol-menu): If bounds are empty (no prefix),
 don't delete region.

lisp/cedet/semantic/ia.el

index 4696388a9c05edec48d4f4da714123c8bb0fe0e6..b17af9a7ce44beecfe15bf35ad1a7e11d05770d5 100644 (file)
@@ -123,7 +123,7 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
              ;; the smart completion engine sometimes fails.
              (semantic-complete-symbol))
        ;; Use try completion to seek a common substring.
-       (let* ((completion-ignore-case (string= (downcase pre) pre))
+       (let* ((completion-ignore-case (and pre (string= (downcase pre) pre)))
               (tc (try-completion (or pre "")  syms)))
          (if (and (stringp tc) (not (string= tc (or pre ""))))
              (let ((tok (semantic-find-first-tag-by-name
@@ -188,7 +188,11 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
        (when ans
          (if (not (semantic-tag-p ans))
              (setq ans (aref (cdr ans) 0)))
-         (delete-region (car (oref a bounds)) (cdr (oref a bounds)))
+         (with-slots ((bnds bounds)) a
+            ;; bounds could be nil if we are completing an empty prefix string
+            ;; (e.g. type constrained within a function argument list)
+            (when (and (car bnds) (cdr bnds))
+              (delete-region (car bnds) (cdr bnds))))
          (semantic-ia-insert-tag ans))
        ))))