]> code.delx.au - gnu-emacs-elpa/commitdiff
Fixed pseudo tooltips on the last line if no trailing newline.
authorNikolaj Schumacher <git@nschum.de>
Wed, 11 Mar 2009 16:14:19 +0000 (17:14 +0100)
committerNikolaj Schumacher <git@nschum.de>
Thu, 19 Mar 2009 21:49:54 +0000 (22:49 +0100)
company.el

index f7fe2406787d4aacf31ce2bd5fa217837cfa3f9d..6ec1d4970371b8214dba66e9b5c115ae05f91e56 100644 (file)
           new
           (company-safe-substring old (+ offset (length new)))))
 
-(defun company-modified-substring (beg end lines column)
+(defun company-modified-substring (beg end lines column nl)
   (let ((old (company-buffer-lines beg end))
         new)
     ;; Inject into old lines.
     ;; Append whole new lines.
     (while lines
       (push (company-modify-line "" (pop lines) column) new))
-    (concat (mapconcat 'identity (nreverse new) "\n")
+    (concat (when nl "\n")
+            (mapconcat 'identity (nreverse new) "\n")
             "\n")))
 
 ;; show
 
 
     (move-to-column 0)
-    (move-to-window-line row)
-    (let ((beg (point))
+
+    (let ((nl (< (move-to-window-line row) row))
+          (beg (point))
           (end (save-excursion
                  (move-to-window-line (min (window-height)
                                            (+ row company-tooltip-limit)))
       (setq company-pseudo-tooltip-overlay (make-overlay beg end))
 
       (overlay-put company-pseudo-tooltip-overlay 'before-string
-                   (company-modified-substring beg end lines column))
+                   (company-modified-substring beg end lines column nl))
       (overlay-put company-pseudo-tooltip-overlay 'invisible t)
       (overlay-put company-pseudo-tooltip-overlay 'window (selected-window)))))