From 88a0bb968562d285381c007bdd7f276c8d73731c Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 25 Nov 2017 20:06:17 +0100
Subject: [PATCH] selecting: do not cancel the softmark when the cursor is not
 moved

The softmark is now only cancelled when the cursor is moved without
Shift being held, not for things like ^L (Refresh), ^C (Position),
or ^G (Help).

This addresses https://savannah.gnu.org/bugs/?52470.
---
 src/nano.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/nano.c b/src/nano.c
index dc7f3740..1209a831 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1687,6 +1687,9 @@ int do_input(bool allow_funcs)
 #endif
 	{
 #ifndef NANO_TINY
+	    filestruct *was_current = openfile->current;
+	    size_t was_x = openfile->current_x;
+
 	    /* If Shifted movement occurs, set the mark. */
 	    if (shift_held && !openfile->mark) {
 		openfile->mark = openfile->current;
@@ -1699,7 +1702,9 @@ int do_input(bool allow_funcs)
 #ifndef NANO_TINY
 	    /* If Shiftless movement occurred, discard a soft mark. */
 	    if (!shift_held && openfile->mark &&
-				openfile->kind_of_mark == SOFTMARK) {
+				openfile->kind_of_mark == SOFTMARK &&
+				(openfile->current_x != was_x ||
+				openfile->current != was_current)) {
 		openfile->mark = NULL;
 		refresh_needed = TRUE;
 	    }
-- 
GitLab