(self-insert-command 1))
(company-post-command)
(should (string= "ab " (buffer-string))))))
+
+(ert-deftest company-pseudo-tooltip-does-not-get-displaced ()
+ (with-temp-buffer
+ (save-window-excursion
+ (set-window-buffer nil (current-buffer))
+ (save-excursion (insert " ff"))
+ (company-mode)
+ (let ((company-frontends '(company-pseudo-tooltip-frontend))
+ (company-begin-commands '(self-insert-command))
+ (company-backends
+ (list (lambda (c &optional arg)
+ (case c (prefix "") (candidates '("a" "b" "c")))))))
+ (let (this-command)
+ (company-complete))
+ (company-post-command)
+ (open-line 1)
+ (company-post-command)
+ (should (eq 2 (overlay-start company-pseudo-tooltip-overlay)))))))
(overlay-get company-pseudo-tooltip-overlay 'company-before))
(overlay-put company-pseudo-tooltip-overlay 'window (selected-window))))
+(defun company-pseudo-tooltip-guard ()
+ (buffer-substring-no-properties
+ (point) (overlay-start company-pseudo-tooltip-overlay)))
+
(defun company-pseudo-tooltip-frontend (command)
"A `company-mode' front-end similar to a tool-tip but based on overlays."
(case command
0))
(new-height (company--pseudo-tooltip-height)))
(unless (and (>= (* old-height new-height) 0)
- (>= (abs old-height) (abs new-height)))
+ (>= (abs old-height) (abs new-height))
+ (equal (company-pseudo-tooltip-guard)
+ (overlay-get company-pseudo-tooltip-overlay
+ 'company-guard)))
;; Redraw needed.
(company-pseudo-tooltip-show-at-point (- (point)
- (length company-prefix)))))
+ (length company-prefix)))
+ (overlay-put company-pseudo-tooltip-overlay
+ 'company-guard (company-pseudo-tooltip-guard))))
(company-pseudo-tooltip-unhide))
(hide (company-pseudo-tooltip-hide)
(setq company-tooltip-offset 0))