nano

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

commit 44814055b5a2012b67405f035834a08648a00217
parent 71f859377d4716a6663813c42be8723f4d86f768
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat,  2 Jun 2018 18:04:36 +0200

tweaks: correct a comment, rewrap a line, and drop some debugging stuff

An add can be contiguous even when the cursor has moved around in the
meantime but has returned to the same spot before more characters are
typed.

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

diff --git a/src/text.c b/src/text.c @@ -693,10 +693,6 @@ void do_undo(void) return; } -#ifdef DEBUG - fprintf(stderr, " >> Undoing a type %d...\n", u->type); -#endif - openfile->current_x = u->begin; switch (u->type) { case ADD: @@ -878,10 +874,6 @@ void do_redo(void) return; } -#ifdef DEBUG - fprintf(stderr, " >> Redoing a type %d...\n", u->type); -#endif - switch (u->type) { case ADD: redidmsg = _("text add"); @@ -1302,20 +1294,17 @@ void add_undo(undo_type action) undo *u = openfile->current_undo; /* The thing we did previously. */ - /* When doing contiguous adds or contiguous cuts -- which means: with - * no cursor movement in between -- don't add a new undo item. */ - if (u && u->mark_begin_lineno == openfile->current->lineno && action == openfile->last_action && - ((action == ADD && u->type == ADD && u->mark_begin_x == openfile->current_x) || - (action == CUT && u->type == CUT && u->xflags < MARK_WAS_SET && keeping_cutbuffer()))) + /* When doing contiguous adds or cuts, don't add a new undo item. */ + if (u != NULL && action == openfile->last_action && action == u->type && + openfile->current->lineno == u->mark_begin_lineno && + ((action == ADD && u->mark_begin_x == openfile->current_x) || + (action == CUT && u->xflags < MARK_WAS_SET && + keeping_cutbuffer()))) return; /* Blow away newer undo items if we add somewhere in the middle. */ discard_until(u, openfile, TRUE); -#ifdef DEBUG - fprintf(stderr, " >> Adding an undo... action = %d\n", action); -#endif - /* Allocate and initialize a new undo item. */ u = (undo *) nmalloc(sizeof(undo)); u->type = action; @@ -1473,10 +1462,6 @@ void update_undo(undo_type action) char *char_buf; int char_len; -#ifdef DEBUG -fprintf(stderr, " >> Updating an undo... action = %d\n", action); -#endif - /* If the action is different or the position changed, don't update the * current record but add a new one instead. */ if (action != openfile->last_action ||