emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/add-vdiff 1102da8 129/258: Avoid subtraction overlays lar


From: Justin Burkett
Subject: [elpa] scratch/add-vdiff 1102da8 129/258: Avoid subtraction overlays larger than window-height
Date: Wed, 17 May 2017 08:13:37 -0400 (EDT)

branch: scratch/add-vdiff
commit 1102da8c1d9a3b7d18e31047bb83e7b204effb81
Author: justbur <address@hidden>
Commit: justbur <address@hidden>

    Avoid subtraction overlays larger than window-height
---
 vdiff.el | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/vdiff.el b/vdiff.el
index 3208adf..b8721d9 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -562,13 +562,27 @@ of a \"word\"."
   'vdiff--insertion-arrow vdiff--insertion-arrow-bits nil 8 'top)
 
 (defun vdiff--make-subtraction-string (n-lines)
-  (let ((n-lines (if (eq 'single vdiff-subtraction-style)
-                     1
-                   n-lines))
-        string)
-    (dotimes (_ n-lines)
-      (push (make-string (1- (vdiff--min-window-width))
-                         vdiff-subtraction-fill-char) string))
+  (let* ((width (1- (vdiff--min-window-width)))
+         (win-height (window-height))
+         (max-lines (floor (* 0.7 win-height)))
+         (truncate (> n-lines max-lines))
+         (trunc-n-lines
+          (cond ((eq 'single vdiff-subtraction-style) 1)
+                (truncate max-lines)
+                (t n-lines)))
+         (truncate-prefix-len 2)
+         string truncate-message)
+    (dotimes (_ trunc-n-lines)
+      (push (make-string width vdiff-subtraction-fill-char) string))
+    (when truncate
+      (setq truncate-message (format " +%d lines " (- n-lines trunc-n-lines)))
+      (push (concat (make-string truncate-prefix-len 
vdiff-subtraction-fill-char)
+                    truncate-message
+                    (make-string (- width truncate-prefix-len
+                                    (length truncate-message))
+                                 vdiff-subtraction-fill-char))
+            string)
+      (setq string (nreverse string)))
     (if (eq vdiff-subtraction-style 'fringe)
         (propertize
          " "



reply via email to

[Prev in Thread] Current Thread [Next in Thread]