semantic: completion fixes
authorEric Ludlam <eric@siege-engine.com>
Sun, 18 Oct 2015 14:17:24 +0000 (10:17 -0400)
committerDavid Engster <deng@randomsample.de>
Sun, 22 Jan 2017 21:25:16 +0000 (22:25 +0100)
* lisp/cedet/semantic/complete.el (semantic-complete-read-tag-engine):
 Don't allow buffer switching.
 (semantic-collector-calculate-completions): Protect against
 cases where the context being completed with isn't a smart completion case.

lisp/cedet/semantic/complete.el

index 5bd76f018a1f94a98d76d1a1690cb95cb0433b89..ba640a2c5f05936c59dada467b0bbc67be22f77f 100644 (file)
@@ -209,7 +209,8 @@ HISTORY is a symbol representing a variable to story the history in."
         (semantic-completion-display-engine displayor)
         (semantic-complete-active-default nil)
         (semantic-complete-current-matched-tag nil)
-        (default-as-tag (semantic-complete-default-to-tag default-tag))
+        (default-as-tag (save-current-buffer
+                          (semantic-complete-default-to-tag default-tag)))
         (default-as-string (when (semantic-tag-p default-as-tag)
                              (semantic-tag-name default-as-tag)))
         )
@@ -1026,14 +1027,19 @@ Output must be in semanticdb Find result format."
                      (eq (compare-strings
                           prefix 0 nil
                           last-prefix 0 (length prefix)) t))
-                  ;; The new prefix is a substring of the old
-                  ;; prefix, and it's longer than one character.
-                  ;; Perform a full search to pull in additional
-                  ;; matches.
-                (let ((context (semantic-analyze-current-context (point))))
-                  ;; Set new context and make first-pass-completions
-                  ;; unbound so that they are newly calculated.
-                  (oset obj context context)
+                ;; The new prefix is a substring of the old
+                ;; prefix, and it's longer than one character.
+                ;; Perform a full search to pull in additional
+                ;; matches.
+                (when (slot-exists-p obj 'context)
+                  ;; If this collector wants an analyzed context,
+                  ;; then restart here.
+                  (save-current-buffer
+                    (set-buffer (oref obj buffer))
+                    (let ((context (semantic-analyze-current-context (point))))
+                      ;; Set new context and make first-pass-completions
+                      ;; unbound so that they are newly calculated.
+                      (oset obj context context)))
                   (when (slot-boundp obj 'first-pass-completions)
                     (slot-makeunbound obj 'first-pass-completions)))
                 nil)))