From a77cb623d20ba661792a2c9c0224a0e65ab7dc09 Mon Sep 17 00:00:00 2001
From: ram <ram>
Date: Sun, 11 Nov 1990 22:53:01 +0000
Subject: [PATCH] Fixed WORTH-USING-INSERT-MODE so that it does the right
 thing.  We must pass in the number of characters saved by doing insertion so
 that we can compare to that.

---
 hemlock/tty-display.lisp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hemlock/tty-display.lisp b/hemlock/tty-display.lisp
index a3dc62817..f6c326b07 100644
--- a/hemlock/tty-display.lisp
+++ b/hemlock/tty-display.lisp
@@ -784,7 +784,8 @@
 				  hunk dl-len dl-pos)))))
 	       (t
 		(if (and (tty-device-insert-string device)
-			 (worth-using-insert-mode device (- dindex sindex)))
+			 (worth-using-insert-mode device (- dindex sindex)
+						  (- dl-len sindex)))
 		    (funcall (tty-device-insert-string device)
 			     hunk sindex dl-pos dl-chars sindex dindex)
 		    (funcall (tty-device-display-string device)
@@ -1043,7 +1044,7 @@
     (setf (tty-device-cursor-x device)
 	  (the fixnum (+ x (the fixnum (- end start)))))))
 
-(defun worth-using-insert-mode (device insert-char-num)
+(defun worth-using-insert-mode (device insert-char-num chars-saved)
   (let* ((init-string (tty-device-insert-init-string device))
 	 (char-init-string (tty-device-insert-char-init-string device))
 	 (char-end-string (tty-device-insert-char-end-string device))
@@ -1058,7 +1059,7 @@
 							char-end-string))
 					   0)))))
     (when end-string (incf cost (length (the simple-string end-string))))
-    (< cost insert-char-num)))
+    (< cost chars-saved)))
 
 (defun delete-char (hunk x y &optional (n 1))
   (declare (fixnum x y n))
-- 
GitLab