nano

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

commit 20971e8392b3d2c8597df757d2b3fb6ac015c113
parent fa454abb1cadc82395034dcb7443722515f1d895
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sat,  9 Jun 2018 16:50:30 -0500

undo: position the cursor properly when undoing/redoing magicline cuts

Take our cue from undoing/redoing line joins: when they take place on
the magicline without --nonewlines, they produce undo/redo items that
don't do anything to the text, but still position the cursor properly.
Reshuffle a bit of code so that we can do the same for magicline cuts.

This fixes https://savannah.gnu.org/bugs/?54032.

Diffstat:
Msrc/text.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -633,16 +633,16 @@ void handle_comment_action(undo *u, bool undoing, bool add_comment) /* Undo a cut, or redo an uncut. */ void undo_cut(undo *u) { - /* If we cut the magicline, we may as well not crash. :/ */ - if (!u->cutbuffer) - return; - /* Get to where we need to uncut from. */ if (u->xflags == WAS_WHOLE_LINE) goto_line_posx(u->mark_begin_lineno, 0); else goto_line_posx(u->mark_begin_lineno, u->mark_begin_x); + /* If we cut the magicline, we may as well not crash. :/ */ + if (!u->cutbuffer) + return; + copy_from_buffer(u->cutbuffer); if (u->xflags != WAS_MARKED_FORWARD && u->type != PASTE) @@ -654,6 +654,8 @@ void redo_cut(undo *u) { filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom; + goto_line_posx(u->lineno, u->begin); + /* If we cut the magicline, we may as well not crash. :/ */ if (!u->cutbuffer) return; @@ -661,8 +663,6 @@ void redo_cut(undo *u) cutbuffer = NULL; cutbottom = NULL; - goto_line_posx(u->lineno, u->begin); - openfile->mark = fsfromline(u->mark_begin_lineno); openfile->mark_x = (u->xflags == WAS_WHOLE_LINE) ? 0 : u->mark_begin_x;