Author: phst
Date: Mon Apr  9 06:31:44 2018
New Revision: 329566

Improve completion experience for headers

Summary: When calling `completing-read', we should provide a default to prevent 
the behavior described in
  Also, don't use an assertion to check whether the user selected a header; 
raise a proper signal instead.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision:


Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Mon Apr  
9 06:31:44 2018
@@ -314,14 +314,18 @@ They are replaced by the single element
               (goto-char (clang-include-fixer--closest-overlay overlays)))
             (cl-flet ((header (info) (let-alist info .Header)))
               ;; The header-infos is already sorted by include-fixer.
-              (let* ((header (completing-read
+              (let* ((headers (mapcar #'header .HeaderInfos))
+                     (header (completing-read
                                "Select include for '%s': " symbol)
-                              (mapcar #'header .HeaderInfos)
-                              nil :require-match nil
-                              'clang-include-fixer--history))
+                              headers nil :require-match nil
+                              'clang-include-fixer--history
+                              ;; Specify a default to prevent the behavior
+                              ;; described in
+                              ;;
+                              (car headers)))
                      (info (cl-find header .HeaderInfos :key #'header :test 
-                (cl-assert info)
+                (unless info (user-error "No header selected"))
                 (setcar .HeaderInfos info)
                 (setcdr .HeaderInfos nil))))
         (mapc #'delete-overlay overlays)))))

cfe-commits mailing list

Reply via email to