From 66e8285fc6dbb1f1583f2037bfb1d4aa9e6b2b81 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Tue, 24 Oct 2017 18:59:15 -0400 Subject: [PATCH] Prevent word wrapping lines which will be truncated later --- magithub-issue.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/magithub-issue.el b/magithub-issue.el index 76e8f6c..9985e1f 100644 --- a/magithub-issue.el +++ b/magithub-issue.el @@ -260,6 +260,7 @@ Each function takes two arguments: (let* ((label-string (format fmt "Preview:")) (label-len (length label-string)) (prefix (make-string label-len ?\ )) + (max-lines 4) did-cut) (insert label-string (if (or (null .body) (string= .body "")) @@ -267,11 +268,18 @@ Each function takes two arguments: (concat (s-trim (with-temp-buffer - (insert (s-word-wrap (- fill-column label-len) .body)) + (insert (s-word-wrap + (- fill-column label-len) + ;; Truncate string to longest possible wrapped + ;; string before wrapping it (peformance) + (substring .body + 0 + (min (* fill-column max-lines) + (length .body))))) (goto-char 0) (let ((lines 0)) (while (and (not (eobp)) - (< (setq lines (1+ lines)) 4)) + (< (setq lines (1+ lines)) max-lines)) (insert prefix) (forward-line)) (unless (= (point) (point-max))