Commit 66e21416 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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
No related merge requests found
Showing with 13 additions and 0 deletions
+13 -0
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
and NONEWLINES is set, there is no next line at which to put the 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. cutting point for a redo. So put it at the very end of the cut.
This fixes Savannah bug #46541. 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> 2015-11-29 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (reset_multis): Evaluate correctly whether to reset * src/color.c (reset_multis): Evaluate correctly whether to reset
......
...@@ -329,6 +329,10 @@ typedef struct undo { ...@@ -329,6 +329,10 @@ typedef struct undo {
/* Where did this action begin or end. */ /* Where did this action begin or end. */
char *strdata; char *strdata;
/* String type data we will use for copying the affected line back. */ /* 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; int xflags;
/* Some flag data we need. */ /* Some flag data we need. */
......
...@@ -611,6 +611,7 @@ void do_undo(void) ...@@ -611,6 +611,7 @@ void do_undo(void)
openfile->current_undo = openfile->current_undo->next; openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER; openfile->last_action = OTHER;
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
openfile->totsize = u->wassize;
set_modified(); set_modified();
} }
...@@ -748,6 +749,7 @@ void do_redo(void) ...@@ -748,6 +749,7 @@ void do_redo(void)
openfile->current_undo = u; openfile->current_undo = u;
openfile->last_action = OTHER; openfile->last_action = OTHER;
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
openfile->totsize = u->newsize;
set_modified(); set_modified();
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
...@@ -957,12 +959,14 @@ void add_undo(undo_type action) ...@@ -957,12 +959,14 @@ void add_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;
u->mark_set = FALSE; u->mark_set = FALSE;
u->wassize = openfile->totsize;
u->xflags = 0; u->xflags = 0;
switch (u->type) { switch (u->type) {
/* We need to start copying data into the undo buffer /* We need to start copying data into the undo buffer
* or we won't be able to restore it later. */ * or we won't be able to restore it later. */
case ADD: case ADD:
u->wassize--;
break; break;
case BACK: case BACK:
/* If the next line is the magic line, don't ever undo this /* 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 ...@@ -1065,6 +1069,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
assert(openfile->undotop != NULL); assert(openfile->undotop != NULL);
u = openfile->undotop; u = openfile->undotop;
u->newsize = openfile->totsize;
switch (u->type) { switch (u->type) {
case ADD: { case ADD: {
#ifdef DEBUG #ifdef DEBUG
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment