branch: externals/company
commit b981dcce423f3899fe1c049d6c772cab0dae9ec8
Merge: 2b77317c4c 1bf7dcd3ce
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    Merge branch 'master' into better-integration
---
 NEWS.md                       |  2 ++
 company-childframe.el         |  5 +++-
 company.el                    | 57 +++++++++++++++++++++++++++++++++++--------
 icons/vscode-dark/filter.svg  |  3 +++
 icons/vscode-dark/search.svg  |  3 +++
 icons/vscode-light/filter.svg |  3 +++
 icons/vscode-light/search.svg |  3 +++
 7 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index a572b15446..f9287f4a6b 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -11,6 +11,8 @@
   (`M-:`). The "pseudo-tooltip" frontend is not supported by this feature,
   `company-childframe` is recommended instead.
 * `C-M-i` is bound to `company-complete-common` when completion is active.
+* Search mode input is displayed at the bottom of the popup
+  ([#1535](https://github.com/company-mode/company-mode/pull/1535)).
 * New built-in frontend using "real graphical" widget for the popup
   ([#1525](https://github.com/company-mode/company-mode/pull/1525)).
   This also adds a hard dependency on the package `posframe`.
diff --git a/company-childframe.el b/company-childframe.el
index 2b4797dbe1..d4bf2d2f5f 100644
--- a/company-childframe.el
+++ b/company-childframe.el
@@ -122,7 +122,10 @@ Users of HiDPI screens might like to set it to 2."
          (before-make-frame-hook)
          (after-make-frame-functions)
          (x-fast-protocol-requests t)
-         (height (min company-tooltip-limit company-candidates-length))
+         (height (min company-tooltip-limit
+                      (if company-search-mode
+                          (1+ company-candidates-length)
+                        company-candidates-length)))
          (company-lines (company--create-lines company-selection height))
          (margin (car company-lines))
          (lines (cdr company-lines))
diff --git a/company.el b/company.el
index f41074c5e9..71d590a919 100644
--- a/company.el
+++ b/company.el
@@ -983,12 +983,16 @@ asynchronous call into synchronous.")
 (defvar company-lighter '(" "
                           (company-candidates
                            (:eval
-                            (if (consp company-backend)
-                                (when company-selection
-                                  (company--group-lighter (nth 
company-selection
-                                                               
company-candidates)
-                                                          
company-lighter-base))
-                              (symbol-name company-backend)))
+                            (cond
+                             ((consp company-backend)
+                              (when company-selection
+                                (company--group-lighter (nth company-selection
+                                                             
company-candidates)
+                                                        company-lighter-base)))
+                             ((symbolp company-backend)
+                              (symbol-name company-backend))
+                             ((functionp company-backend)
+                              "company-<lambda>")))
                            company-lighter-base))
   "Mode line lighter for Company.
 
@@ -1984,6 +1988,7 @@ end of the match."
     (event . "symbol-event.svg")
     (field . "symbol-field.svg")
     (file . "symbol-file.svg")
+    (filter . "filter.svg")
     (folder . "folder.svg")
     (interface . "symbol-interface.svg")
     (keyword . "symbol-keyword.svg")
@@ -1994,6 +1999,7 @@ end of the match."
     (operator . "symbol-operator.svg")
     (property . "symbol-property.svg")
     (reference . "references.svg")
+    (search . "search.svg")
     (snippet . "symbol-snippet.svg")
     (string . "symbol-string.svg")
     (struct . "symbol-structure.svg")
@@ -2097,6 +2103,7 @@ end of the match."
     (enum "e" font-lock-builtin-face)
     (field "f" font-lock-variable-name-face)
     (file "f" font-lock-string-face)
+    (filter "!" minibuffer-prompt)
     (folder "d" font-lock-doc-face)
     (interface "i" font-lock-type-face)
     (keyword "k" font-lock-keyword-face)
@@ -2107,6 +2114,7 @@ end of the match."
     (operator "o" font-lock-comment-delimiter-face)
     (property "p" font-lock-variable-name-face)
     (reference "r" font-lock-doc-face)
+    (search "q" minibuffer-prompt)
     (snippet "S" font-lock-string-face)
     (string "s" font-lock-string-face)
     (struct "%" font-lock-variable-name-face)
@@ -2773,6 +2781,7 @@ each one wraps a part of the input string."
 
 (defvar-local company-search-string "")
 
+;; FIXME: Delete later.
 (defvar company-search-lighter '(" "
                                  (company-search-filtering "Filter" "Search")
                                  ": \""
@@ -2990,7 +2999,7 @@ each one wraps a part of the input string."
   "Search mode for completion candidates.
 Don't start this directly, use `company-search-candidates' or
 `company-filter-candidates'."
-  :lighter company-search-lighter
+  :lighter nil
   (if company-search-mode
       (if (company-manual-begin)
           (progn
@@ -3038,8 +3047,8 @@ uses the search string to filter the completion 
candidates."
 This works the same way as `company-search-candidates' immediately
 followed by `company-search-toggle-filtering'."
   (interactive)
-  (company-search-mode 1)
-  (setq company-search-filtering t))
+  (setq company-search-filtering t)
+  (company-search-mode 1))
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -4123,6 +4132,8 @@ but adjust the expected values appropriately."
         previous
         remainder
         scrollbar-bounds)
+    (when company-search-mode
+      (cl-decf limit))
 
     ;; Maybe clear old offset.
     (when (< len (+ company-tooltip-offset limit))
@@ -4237,6 +4248,10 @@ but adjust the expected values appropriately."
       (when remainder
         (push (company--scrollpos-line remainder width left-margin-size) new))
 
+      (when company-search-mode
+        (push (company--search-line width right-margin)
+              new))
+
       (cons
        left-margin-size
        (nreverse new)))))
@@ -4289,6 +4304,25 @@ Value of SELECTED determines the added face."
                   'company-tooltip-quick-access-selection
                 'company-tooltip-quick-access)))
 
+(defun company--search-line (width right-margin)
+  (let* ((company-backend (lambda (command &rest _)
+                            (and (eq command 'kind)
+                                 (if company-search-filtering
+                                     'filter
+                                   'search))))
+         (left (funcall company-format-margin-function "" nil))
+         (line (concat
+                company-search-string))
+         (width (+ (company--string-width left) width (length right-margin))))
+    (unless (display-graphic-p) (cl-incf width))
+    (setq line (company-safe-substring (concat left
+                                               (propertize
+                                                company-search-string
+                                                'face 'underline))
+                                       0 width))
+    (add-face-text-property 0 width 'company-tooltip nil line)
+    line))
+
 ;; show
 
 (defvar-local company-pseudo-tooltip-overlay nil)
@@ -4312,7 +4346,10 @@ Value of SELECTED determines the added face."
 Returns a negative number if the tooltip should be displayed above point."
   (let* ((lines (company--row))
          (below (- (company--window-height) 1 lines)))
-    (if (and (< below (min company-tooltip-minimum company-candidates-length))
+    (if (and (< below (min company-tooltip-minimum
+                           (if company-search-mode
+                               (1+ company-candidates-length)
+                             company-candidates-length)))
              (> lines below))
         (- (max 3 (min company-tooltip-limit lines)))
       (max 3 (min company-tooltip-limit below)))))
diff --git a/icons/vscode-dark/filter.svg b/icons/vscode-dark/filter.svg
new file mode 100644
index 0000000000..5af9646998
--- /dev/null
+++ b/icons/vscode-dark/filter.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15 2V3.66963L10 
8.42874V14H6V8.42874L1 3.66963V2H15ZM7 8V13H9V8L14 3.24089V3H2V3.24089L7 8Z" 
fill="#C5C5C5"/>
+</svg>
diff --git a/icons/vscode-dark/search.svg b/icons/vscode-dark/search.svg
new file mode 100644
index 0000000000..eba698fe45
--- /dev/null
+++ b/icons/vscode-dark/search.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 24 24" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+<path d="M15.25 1.02546e-06C13.6605 -0.000791296 12.1046 0.457574 10.7694 
1.32007C9.43422 2.18256 8.37657 3.4124 7.72375 4.8617C7.07094 6.31099 6.85077 
7.91801 7.0896 9.4895C7.32843 11.061 8.01604 12.5301 9.06995 13.72L1 22.88L2.12 
23.88L10.17 14.76C11.2055 15.5693 12.4192 16.1196 13.7103 16.365C15.0014 
16.6104 16.3325 16.5437 17.5927 16.1707C18.8528 15.7976 20.0055 15.1288 20.955 
14.2201C21.9044 13.3114 22.623 12.1891 23.0509 10.9465C23.4789 9.70396 23.6038 
8.37703 23.4153 7.07642C23.22 [...]
+</svg>
diff --git a/icons/vscode-light/filter.svg b/icons/vscode-light/filter.svg
new file mode 100644
index 0000000000..30a559dc78
--- /dev/null
+++ b/icons/vscode-light/filter.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.0002 2V3.66963L10.0002 
8.42874V14H6.00024V8.42874L1.00024 3.66963V2H15.0002ZM7.00024 
8V13H9.00024V8L14.0002 3.24089V3H2.00024V3.24089L7.00024 8Z" fill="#424242"/>
+</svg>
diff --git a/icons/vscode-light/search.svg b/icons/vscode-light/search.svg
new file mode 100644
index 0000000000..578a48aff8
--- /dev/null
+++ b/icons/vscode-light/search.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 24 24" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+<path d="M15.2502 1.02546e-06C13.6607 -0.000791296 12.1048 0.457574 10.7697 
1.32007C9.43447 2.18256 8.37681 3.4124 7.724 4.8617C7.07118 6.31099 6.85102 
7.91801 7.08984 9.4895C7.32867 11.061 8.01628 12.5301 9.07019 13.72L1.00024 
22.88L2.12024 23.88L10.1703 14.76C11.2057 15.5693 12.4195 16.1196 13.7106 
16.365C15.0017 16.6104 16.3328 16.5437 17.5929 16.1707C18.853 15.7976 20.0058 
15.1288 20.9552 14.2201C21.9046 13.3114 22.6232 12.1891 23.0511 10.9465C23.4791 
9.70396 23.6041 8.37703 23.4155  [...]
+</svg>

Reply via email to