diff --git a/src/nano.c b/src/nano.c
index 1c7c4dec9c630b5c0eb4eff4fa877fac0a0d4980..7835af5ca52f1745deca7329f27416f00d8f39b8 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1621,6 +1621,19 @@ int do_mouse(void)
 }
 #endif /* ENABLE_MOUSE */
 
+/* Return TRUE when the given function is a cursor-moving command. */
+bool wanted_to_move(void *func)
+{
+	return func == do_left || func == do_right ||
+			func == do_up || func == do_down ||
+			func == do_home || func == do_end ||
+			func == do_prev_word_void || func == do_next_word_void ||
+			func == do_para_begin_void || func == do_para_end_void ||
+			func == do_prev_block || func == do_next_block ||
+			func == do_page_up || func == do_page_down ||
+			func == to_first_line || func == to_last_line;
+}
+
 /* Read in a keystroke.  Act on the keystroke if it is a shortcut or a toggle;
  * otherwise, insert it into the edit buffer.  If allow_funcs is FALSE, don't
  * do anything with the keystroke -- just return it. */
@@ -1770,8 +1783,7 @@ int do_input(bool allow_funcs)
 				if (!shift_held && openfile->kind_of_mark == SOFTMARK &&
 									(openfile->current != was_current ||
 									openfile->current_x != was_x ||
-									(shortcut->func >= to_first_line &&
-									shortcut->func <= do_right))) {
+									wanted_to_move(shortcut->func))) {
 					openfile->mark = NULL;
 					refresh_needed = TRUE;
 				} else if (openfile->current != was_current)