From a1fba434520be4320cfe76d0a62fb3bd42658e2d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 20 Jul 2017 09:41:27 +0200 Subject: [PATCH] pasting: restore the cap on the number of chunks to move backward This fixes https://savannah.gnu.org/bugs/?51514. --- src/winio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/winio.c b/src/winio.c index 2d8ffc45..68405326 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2803,6 +2803,10 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge) { int i; + /* Don't move more chunks than the window can hold. */ + if (nrows > editwinrows - 1) + nrows = (editwinrows < 2) ? 1 : editwinrows - 1; + #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { /* Recede through the requested number of chunks. */