From 907ba3a2e2f19354870e029da1af80bc7d794bc2 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 25 Apr 2016 15:44:52 +0200
Subject: [PATCH] scrolling: catch the special case of reading a file from
 standard input

Since commit dac0aa1, nano would leave edittop at current after reading
data from standard input, meaning that everything that had been read in
was invisible, "scrolled off" the top of the screen.  Correct this by
explicitly setting edittop.

The above does not happen for ^R (^X) because it has a special mechanism
to save and restore edittop.  Nor does it happen for ^R ^X M-F because it
sets current to the top of the file and refreshing the screen will make
edittop follow, or -- in case just one unterminated line was read in --
edittop will already be equal to current.
---
 src/nano.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nano.c b/src/nano.c
index d87dbc17..5d4a40f3 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1167,6 +1167,8 @@ void finish_stdin_pager(void)
 	nperror("fopen");
 
     read_file(f, 0, "stdin", TRUE, FALSE);
+    openfile->edittop = openfile->fileage;
+
     ttystdin = open("/dev/tty", O_RDONLY);
     if (!ttystdin)
 	die(_("Couldn't reopen stdin from keyboard, sorry\n"));
-- 
GitLab