undo: put the cursor back on the original row for a full-buffer operation
When an operation that replaces the entire buffer is undone, the position of the viewport is lost. Compensate for this by storing the row of the cursor in the undo item, and, after executing the undo item, arranging the viewport so that the cursor is back on the original row -- the row where the operation was invoked. This fixes https://savannah.gnu.org/bugs/?57039.master
parent
101987f5c6
commit
0374708597
|
@ -642,6 +642,8 @@ void do_undo(void)
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
undidmsg = u->strdata;
|
undidmsg = u->strdata;
|
||||||
goto_line_posx(u->lineno, u->begin);
|
goto_line_posx(u->lineno, u->begin);
|
||||||
|
openfile->current_y = u->mark_begin_lineno;
|
||||||
|
adjust_viewport(STATIONARY);
|
||||||
break;
|
break;
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
openfile->current_undo = openfile->current_undo->next;
|
openfile->current_undo = openfile->current_undo->next;
|
||||||
|
@ -806,6 +808,7 @@ void do_redo(void)
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
redidmsg = u->strdata;
|
redidmsg = u->strdata;
|
||||||
goto_line_posx(u->lineno, u->begin);
|
goto_line_posx(u->lineno, u->begin);
|
||||||
|
adjust_viewport(STATIONARY);
|
||||||
break;
|
break;
|
||||||
case INDENT:
|
case INDENT:
|
||||||
handle_indent_action(u, FALSE, TRUE);
|
handle_indent_action(u, FALSE, TRUE);
|
||||||
|
@ -1224,6 +1227,7 @@ void add_undo(undo_type action, const char *message)
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
|
u->mark_begin_lineno = openfile->current_y;
|
||||||
case COUPLE_END:
|
case COUPLE_END:
|
||||||
u->strdata = mallocstrcpy(NULL, _(message));
|
u->strdata = mallocstrcpy(NULL, _(message));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue