Storing the correct end position of an inserted file,

and using it for an undo and redo.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2015-11-12 19:01:57 +00:00
parent bde996db67
commit ec26fd5e7c
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2015-11-12 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_undo, update_undo): Store the correct end position of
an inserted file, and use it when undoing. Fixes Savannah bug #46414.
2015-11-11 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_redo, update_undo): Redo an Enter from the stored
undo data, instead of running do_enter() again, because the latter

View File

@ -587,7 +587,7 @@ void do_undo(void)
* how many lines were inserted due to being partitioned before read_file
* was called. So we add its value here. */
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
openfile->mark_begin_x = 0;
openfile->mark_begin_x = u->mark_begin_x;
openfile->mark_set = TRUE;
goto_line_posx(u->lineno, u->begin);
cut_marked();
@ -1154,7 +1154,14 @@ fprintf(stderr, " >> Updating... action = %d, fs->last_action = %d, openfile->c
u->lineno = openfile->current->lineno;
break;
case INSERT:
/* Store the number of lines of the insertion plus one. */
u->mark_begin_lineno = openfile->current->lineno;
/* When the insertion contains no newline, store the adjusted
* x position; otherwise, store the length of the last line. */
if (openfile->fileage == openfile->filebot)
u->mark_begin_x = openfile->current_x;
else
u->mark_begin_x = strlen(openfile->filebot->data);
break;
case ENTER:
u->strdata = mallocstrcpy(NULL, fs->current->data);