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);