fix(notable): Truncate first lines if they don't fit the window

Change-Id: I00746aa285d7854b8e35b6d00aa7c608ccf8ce77
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1988
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Vincent Ambo 2020-09-17 16:57:21 +01:00 committed by tazjin
parent 30066b4ba0
commit 5e22faec85

View file

@ -204,10 +204,14 @@
(check-type id integer)
(check-type note notable--note)
(let ((start (point))
(first-line (car (s-lines (notable--note-content note))))
(date (dottime-format (seconds-to-time
(notable--note-time note)))))
(let* ((start (point))
(date (dottime-format (seconds-to-time
(notable--note-time note))))
(first-line (truncate-string-to-width
(car (s-lines (notable--note-content note)))
;; Length of the window, minus the date prefix:
(- (window-width) (+ 2 (length date)))
nil nil 1)))
(insert (propertize (s-concat date " " first-line)
'notable-note-id id))
(insert "\n")))