   (if (ycmd-running?)
       (mapcar
        'company-ycmd-construct-candidate
-       (assoc-default 'completions (ycmd-get-completions (point))))
+       (assoc-default
+        'completions
+        (with-local-quit
+          (ycmd-get-completions (point)))))
     nil))
 
 (defun company-ycmd-get-metadata (candidate)

(defun company-ycmd-get-annotation (candidate)
  (format " [%s]" (get-text-property 0 'kind candidate)))

(defun company-ycmd-backend (command &optional arg &rest ignored)
  (interactive (list 'interactive))

  ; See company.el for more info.
  (case command
    (interactive (company-begin-backend 'company-ycmd-backend))
    (prefix (and (memq major-mode company-ycmd-modes)
                 buffer-file-name
                 (ycmd-running?)
                 (not (company-in-string-or-comment))
                 (company-grab-symbol)))
    (candidates
     (cons :async
           (lambda (cb)
             (funcall cb (company-ycmd-candidates)))))
    (meta (company-ycmd-get-metadata arg))
    (annotation (company-ycmd-get-annotation arg))
    (no-cache 't))) ; Don't cache. It interferes with fuzzy matching.

(defcustom company-ycmd-modes '(c++-mode python-mode csharp-mode)
  "The list of modes for which company-ycmd will attempt completions.")

(defconst company-ycmd-last-candidates nil)

(defun company-ycmd-construct-candidate (src)
  (let ((candidate (assoc-default 'insertion_text src)))
    (dolist (prop company-ycmd-completion-properties candidate)
