undo: store the correct cursor position after a paired cut+insert
And restore the cursor to this position when redoing the cut+insert. Also remove two unneeded conditions. This fully fixes https://savannah.gnu.org/bugs/?54466.master
parent
ec339d3b08
commit
03f9761c35
11
src/text.c
11
src/text.c
|
@ -797,7 +797,6 @@ void do_undo(void)
|
||||||
break;
|
break;
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
undidmsg = u->strdata;
|
undidmsg = u->strdata;
|
||||||
if (u->xflags != MARK_WAS_SET)
|
|
||||||
goto_line_posx(u->lineno, u->begin);
|
goto_line_posx(u->lineno, u->begin);
|
||||||
break;
|
break;
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
|
@ -967,12 +966,11 @@ void do_redo(void)
|
||||||
openfile->current_undo = u;
|
openfile->current_undo = u;
|
||||||
do_redo();
|
do_redo();
|
||||||
do_redo();
|
do_redo();
|
||||||
if (u->xflags != MARK_WAS_SET)
|
|
||||||
goto_line_posx(u->lineno, u->begin);
|
|
||||||
do_redo();
|
do_redo();
|
||||||
return;
|
return;
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
redidmsg = u->strdata;
|
redidmsg = u->strdata;
|
||||||
|
goto_line_posx(u->lineno, u->begin);
|
||||||
break;
|
break;
|
||||||
case INDENT:
|
case INDENT:
|
||||||
handle_indent_action(u, FALSE, TRUE);
|
handle_indent_action(u, FALSE, TRUE);
|
||||||
|
@ -1471,6 +1469,7 @@ void update_undo(undo_type action)
|
||||||
* current record but add a new one instead. */
|
* current record but add a new one instead. */
|
||||||
if (action != openfile->last_action ||
|
if (action != openfile->last_action ||
|
||||||
(action != ENTER && action != CUT && action != INSERT &&
|
(action != ENTER && action != CUT && action != INSERT &&
|
||||||
|
action != COUPLE_END &&
|
||||||
openfile->current->lineno != openfile->current_undo->lineno)) {
|
openfile->current->lineno != openfile->current_undo->lineno)) {
|
||||||
add_undo(action);
|
add_undo(action);
|
||||||
return;
|
return;
|
||||||
|
@ -1565,7 +1564,10 @@ void update_undo(undo_type action)
|
||||||
u->mark_begin_lineno = openfile->current->lineno;
|
u->mark_begin_lineno = openfile->current->lineno;
|
||||||
u->mark_begin_x = openfile->current_x;
|
u->mark_begin_x = openfile->current_x;
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
|
break;
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
|
u->lineno = openfile->current->lineno;
|
||||||
|
u->begin = openfile->current_x;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusline(ALERT, "Wrong undo update type -- please report a bug");
|
statusline(ALERT, "Wrong undo update type -- please report a bug");
|
||||||
|
@ -2915,6 +2917,9 @@ const char *do_alt_speller(char *tempfile_name)
|
||||||
goto_line_posx(lineno_save, current_x_save);
|
goto_line_posx(lineno_save, current_x_save);
|
||||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||||
openfile->current_x = strlen(openfile->current->data);
|
openfile->current_x = strlen(openfile->current->data);
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
update_undo(COUPLE_END);
|
||||||
|
#endif
|
||||||
openfile->placewewant = pww_save;
|
openfile->placewewant = pww_save;
|
||||||
adjust_viewport(STATIONARY);
|
adjust_viewport(STATIONARY);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue