Storing and retrieving the correct file size before and after an action.

This fixes Savannah bug #45523.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5456 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-11-30 16:21:51 +00:00
parent 6b1566023a
commit 66e21416af
3 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,9 @@
and NONEWLINES is set, there is no next line at which to put the
cutting point for a redo. So put it at the very end of the cut.
This fixes Savannah bug #46541.
* src/text.c (add_undo, update_undo, do_undo, do_redo), src/nano.h:
Store and retrieve the correct file size before and after an action.
This fixes Savannah bug #45523.
2015-11-29 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (reset_multis): Evaluate correctly whether to reset

View File

@ -329,6 +329,10 @@ typedef struct undo {
/* Where did this action begin or end. */
char *strdata;
/* String type data we will use for copying the affected line back. */
size_t wassize;
/* The file size before the action. */
size_t newsize;
/* The file size after the action. */
int xflags;
/* Some flag data we need. */

View File

@ -611,6 +611,7 @@ void do_undo(void)
openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER;
openfile->placewewant = xplustabs();
openfile->totsize = u->wassize;
set_modified();
}
@ -748,6 +749,7 @@ void do_redo(void)
openfile->current_undo = u;
openfile->last_action = OTHER;
openfile->placewewant = xplustabs();
openfile->totsize = u->newsize;
set_modified();
}
#endif /* !NANO_TINY */
@ -957,12 +959,14 @@ void add_undo(undo_type action)
u->mark_begin_lineno = openfile->current->lineno;
u->mark_begin_x = openfile->current_x;
u->mark_set = FALSE;
u->wassize = openfile->totsize;
u->xflags = 0;
switch (u->type) {
/* We need to start copying data into the undo buffer
* or we won't be able to restore it later. */
case ADD:
u->wassize--;
break;
case BACK:
/* If the next line is the magic line, don't ever undo this
@ -1065,6 +1069,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
assert(openfile->undotop != NULL);
u = openfile->undotop;
u->newsize = openfile->totsize;
switch (u->type) {
case ADD: {
#ifdef DEBUG