From 2f182d8d513907a70ebd0d5042da0dbe0a4835dd Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Thu, 15 Jun 2006 22:58:10 +0000 Subject: (term-handle-scroll, term-delete-lines) (term-insert-lines): Fix off by one errors. --- lisp/term.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lisp/term.el') diff --git a/lisp/term.el b/lisp/term.el index 8e2e0773121..8dafcfc894b 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -3613,7 +3613,7 @@ all pending output has been dealt with.")) (progn ;; Delete scroll-needed lines at term-scroll-end, ;; then insert scroll-needed lines. - (term-vertical-motion (1- term-scroll-end)) + (term-vertical-motion term-scroll-end) (end-of-line) (setq save-top (point)) (term-vertical-motion scroll-needed) @@ -3767,11 +3767,12 @@ Should only be called when point is at the start of a screen line." (save-current-column term-current-column) (save-start-line-column term-start-line-column) (save-current-row (term-current-row))) - (when (>= (+ save-current-row lines) term-scroll-end) - (setq lines (- lines (- (+ save-current-row lines) term-scroll-end)))) + ;; The number of inserted lines shouldn't exceed the scroll region end. + (when (> (+ save-current-row lines) (1+ term-scroll-end)) + (setq lines (- lines (- (+ save-current-row lines) (1+ term-scroll-end))))) (term-down lines) (delete-region start (point)) - (term-down (- term-scroll-end save-current-row lines)) + (term-down (- (1+ term-scroll-end) save-current-row lines)) (term-insert-char ?\n lines) (setq term-current-column save-current-column) (setq term-start-line-column save-start-line-column) @@ -3792,9 +3793,9 @@ Should only be called when point is at the start of a screen line." (term-down (- term-scroll-start save-current-row)) (setq start (point))) ;; The number of inserted lines shouldn't exceed the scroll region end. - (when (>= (+ save-current-row lines) term-scroll-end) - (setq lines (- lines (- (+ save-current-row lines) term-scroll-end)))) - (term-down (- term-scroll-end save-current-row lines))) + (when (> (+ save-current-row lines) (1+ term-scroll-end)) + (setq lines (- lines (- (+ save-current-row lines)(1+ term-scroll-end))))) + (term-down (- (1+ term-scroll-end) save-current-row lines))) (setq start-deleted (point)) (term-down lines) (delete-region start-deleted (point)) -- cgit v1.2.1