[clang-tools-extra] r329566 - Improve completion experience for headers
Philipp Stephani via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 9 06:31:44 PDT 2018
Author: phst
Date: Mon Apr 9 06:31:44 2018
New Revision: 329566
URL: http://llvm.org/viewvc/llvm-project?rev=329566&view=rev
Log:
Improve completion experience for headers
Summary: When calling `completing-read', we should provide a default to prevent the behavior described in https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection. 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: https://reviews.llvm.org/D43969
Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=329566&r1=329565&r2=329566&view=diff
==============================================================================
--- 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
(clang-include-fixer--format-message
"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
+ ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+ (car headers)))
(info (cl-find header .HeaderInfos :key #'header :test #'string=)))
- (cl-assert info)
+ (unless info (user-error "No header selected"))
(setcar .HeaderInfos info)
(setcdr .HeaderInfos nil))))
(mapc #'delete-overlay overlays)))))
More information about the cfe-commits
mailing list