emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e692260 15/66: Show numbers in tooltip irrespective of scr


From: Dmitry Gutov
Subject: [elpa] master e692260 15/66: Show numbers in tooltip irrespective of scrolling
Date: Tue, 13 Jan 2015 02:44:47 +0000

branch: master
commit e692260303544d0cdda75d9734bfe0ce44cc26e9
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Show numbers in tooltip irrespective of scrolling
---
 NEWS.md    |    2 ++
 company.el |   20 +++++++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index a527c04..8494f08 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
 
 ## Next
 
+* `company-show-numbers` and `company-complete-number` now use visual numbering
+  of the candidates, taking into account only the ones currently displayed.
 * `company-complete-number` can be bound to keypad numbers directly, with or
   without modifiers.
 * `company-cmake` supports expansion of `<LANG>` and `<CONFIG>` placeholders
diff --git a/company.el b/company.el
index 3258f16..fcb100e 100644
--- a/company.el
+++ b/company.el
@@ -1857,7 +1857,7 @@ inserted."
       (setq this-command 'company-complete-common))))
 
 (defun company-complete-number (n)
-  "Insert the Nth candidate.
+  "Insert the Nth candidate visible in the tooltip.
 To show the number next to the candidates in some back-ends, enable
 `company-show-numbers'.  When called interactively, uses the last typed
 character, stripping the modifiers.  That character must be a digit."
@@ -1871,10 +1871,12 @@ character, stripping the modifiers.  That character 
must be a digit."
                 (n (- char ?0)))
            (if (zerop n) 10 n))))
   (when (company-manual-begin)
-    (and (or (< n 1) (> n company-candidates-length))
+    (and (or (< n 1) (> n (- company-candidates-length
+                             company-tooltip-offset)))
          (error "No candidate number %d" n))
     (cl-decf n)
-    (company-finish (nth n company-candidates))))
+    (company-finish (nth (+ n company-tooltip-offset)
+                         company-candidates))))
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -2281,7 +2283,6 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
 
 (defun company--create-lines (selection limit)
   (let ((len company-candidates-length)
-        (numbered 99999)
         (window-width (company--window-width))
         lines
         width
@@ -2335,16 +2336,13 @@ If SHOW-VERSION is non-nil, show the version in the 
echo area."
 
     (setq width (min window-width
                      (max company-tooltip-minimum-width
-                          (if (and company-show-numbers
-                                   (< company-tooltip-offset 10))
+                          (if company-show-numbers
                               (+ 2 width)
                             width))))
 
-    ;; number can make tooltip too long
-    (when company-show-numbers
-      (setq numbered company-tooltip-offset))
-
-    (let ((items (nreverse items)) new)
+    (let ((items (nreverse items))
+          (numbered (if company-show-numbers 0 99999))
+          new)
       (when previous
         (push (company--scrollpos-line previous width) new))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]