From: Benno Schulenberg Date: Thu, 12 Nov 2015 19:01:57 +0000 (+0000) Subject: Storing the correct end position of an inserted file, X-Git-Tag: v2.5.0~58 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ec26fd5e7c8a2fae9bc6756ab28978cd9a0a55d3;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 63a5eecf..8c395b38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ +2015-11-12 Benno Schulenberg + * 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 - * src/text.c (do_redo, update_undo): Redo an Enter from the stored + * src/text.c (do_redo, update_undo): Redo an Enter from the stored undo data, instead of running do_enter() again, because the latter will behave differently depending on the setting of autoindent. This addresses Debian bug #793053 reported by Clancy. diff --git a/src/text.c b/src/text.c index 1f554ded..87dc554c 100644 --- a/src/text.c +++ b/src/text.c @@ -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);