From a4c2b99e4099f41f9b57e58a95ac527fb9787102 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Wed, 29 Apr 2009 22:34:27 +0000 Subject: [PATCH] More wrapping redo fixes. Just make do-wrap() undo aware. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4394 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/nano.c | 2 +- src/proto.h | 2 +- src/text.c | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/nano.c b/src/nano.c index 19a81cd0..8f03bd5b 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1909,7 +1909,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) if (!ISSET(NO_WRAP)) { bool do_refresh_save = do_refresh; - do_refresh = do_wrap(openfile->current); + do_refresh = do_wrap(openfile->current, FALSE); /* If we needed to call edit_refresh() before this, we'll * still need to after this. */ diff --git a/src/proto.h b/src/proto.h index 752bb1e4..94866cb5 100644 --- a/src/proto.h +++ b/src/proto.h @@ -631,7 +631,7 @@ bool execute_command(const char *command); #endif #ifndef DISABLE_WRAPPING void wrap_reset(void); -bool do_wrap(filestruct *line); +bool do_wrap(filestruct *line, bool undoing); #endif #if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY) ssize_t break_line(const char *line, ssize_t goal diff --git a/src/text.c b/src/text.c index e7131fe4..36300066 100644 --- a/src/text.c +++ b/src/text.c @@ -612,16 +612,9 @@ void do_redo(void) break; case SPLIT: undidmsg = _("line wrap"); - data = mallocstrncpy(NULL, f->data, u->begin); - data[u->begin] = '\0'; - free(f->data); - f->data = data; - if (u->strdata2 == NULL) { - t = make_new_node(f); - t->data = mallocstrcpy(NULL, u->strdata); - splice_node(f, t, f->next); - } else - f->next->data = mallocstrcpy(f->next->data, u->strdata2); + if (u->xflags & UNDO_SPLIT_MADENEW) + prepend_wrap = TRUE; + do_wrap(f, TRUE); renumber(f); break; case UNSPLIT: @@ -970,7 +963,7 @@ void update_undo(undo_type action) /* Change to an add if we're not using the same undo struct that we should be using */ if (action != fs->last_action - || (action != CUT && action != INSERT + || (action != CUT && action != INSERT && action != SPLIT && openfile->current->lineno != fs->current_undo->lineno)) { add_undo(action); return; @@ -1087,7 +1080,7 @@ void wrap_reset(void) /* We wrap the given line. Precondition: we assume the cursor has been * moved forward since the last typed character. Return TRUE if we * wrapped, and FALSE otherwise. */ -bool do_wrap(filestruct *line) +bool do_wrap(filestruct *line, bool undoing) { size_t line_len; /* The length of the line we wrap. */ @@ -1152,7 +1145,8 @@ bool do_wrap(filestruct *line) return FALSE; #ifndef NANO_TINY - add_undo(SPLIT); + if (!undoing) + add_undo(SPLIT); /* If autoindent is turned on, and we're on the character just after * the indentation, we don't wrap. */ @@ -1248,6 +1242,8 @@ bool do_wrap(filestruct *line) null_at(&line->data, wrap_loc); if (prepending) { + if (!undoing) + update_undo(SPLIT); /* If we're prepending, copy the text from the next line, minus * the indentation that we already copied above. */ strcat(new_line, next_line); -- 2.39.5