selecting: don't cancel a softmark when just scrolling the screen

As, since commit 0e30177d, the scrollup and scrolldown commands
no longer intend to move the cursor, they should not be seen as
movement functions.

Also, it is not guaranteed that functions are ordered in the same
way in the binary as in the source code, so an ordered comparison
of function pointers will not always work.

This fixes https://savannah.gnu.org/bugs/?53333.
This commit is contained in:
Benno Schulenberg 2018-03-18 13:44:57 +01:00
parent dcda98fb73
commit 95989e7dfe

View File

@ -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)