nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit ec26fd5e7c8a2fae9bc6756ab28978cd9a0a55d3
parent bde996db67e044352f4e279f0e5c80d5097510f3
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Thu, 12 Nov 2015 19:01:57 +0000

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

Diffstat:
MChangeLog | 6+++++-
Msrc/text.c | 9++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,9 @@ +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 + * 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 @@ -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);