feat(emacs/lean-company): truncate string if it's longer than 90% of window-width

Also add "..." in the end

Close #137
This commit is contained in:
Soonho Kong 2014-09-05 08:46:58 -07:00
parent 561753e7f1
commit db60a56056

View file

@ -53,12 +53,14 @@ triggers a completion immediately."
(candidate-len (length candidate)) (candidate-len (length candidate))
(entry-width (+ candidate-len (entry-width (+ candidate-len
annotation-len)) annotation-len))
(window-width (window-body-width))) (allowed-width (truncate (* 0.90 (window-body-width)))))
(when (> entry-width window-width) (when (> entry-width allowed-width)
(setq annotation-str (setq annotation-str
(concat
(substring-no-properties annotation-str (substring-no-properties annotation-str
0 0
(- window-width candidate-len)))) (- allowed-width candidate-len 3))
"...")))
annotation-str)))) annotation-str))))
;;;###autoload ;;;###autoload