From f3e2ad945dabf9518c5f884d6207948ce80732ac Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 6 Apr 2017 19:37:36 +0200
Subject: [PATCH] display: with softwrap, show the cursor where the eye expects
 it

When a multi-column character straddles a chunk boundary, and the
preferred column (placewewant) for the cursor is zero, cheat: show
the cursor not where the character starts but on the beginning of
the next row.  This makes the cursor move smoothly in the leftmost
column of the screen when using <Up> and <Down> and such, instead
of jumping around.

In this way the scrolling logic won't get confused and the screen
will scroll properly when stepping beyond the top or bottom row.

This fixes https://savannah.gnu.org/bugs/?50687.
---
 src/winio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/winio.c b/src/winio.c
index c26a2ff5..78e6f49e 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2287,6 +2287,12 @@ void reset_cursor(void)
 	/* Add the number of wraps in the current line before the cursor. */
 	row += xpt / editwincols;
 	col = xpt % editwincols;
+
+	/* If the cursor ought to be in column zero, nudge it there. */
+	if (openfile->placewewant % editwincols == 0 && col != 0) {
+	    row++;
+	    col = 0;
+	}
     } else
 #endif
     {
-- 
GitLab