Commit a4c2b99e authored by Chris Allegretta's avatar Chris Allegretta
Browse files

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
No related merge requests found
Showing with 11 additions and 15 deletions
+11 -15
...@@ -1909,7 +1909,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1909,7 +1909,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if (!ISSET(NO_WRAP)) { if (!ISSET(NO_WRAP)) {
bool do_refresh_save = do_refresh; 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 /* If we needed to call edit_refresh() before this, we'll
* still need to after this. */ * still need to after this. */
......
...@@ -631,7 +631,7 @@ bool execute_command(const char *command); ...@@ -631,7 +631,7 @@ bool execute_command(const char *command);
#endif #endif
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
void wrap_reset(void); void wrap_reset(void);
bool do_wrap(filestruct *line); bool do_wrap(filestruct *line, bool undoing);
#endif #endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY) #if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal ssize_t break_line(const char *line, ssize_t goal
......
...@@ -612,16 +612,9 @@ void do_redo(void) ...@@ -612,16 +612,9 @@ void do_redo(void)
break; break;
case SPLIT: case SPLIT:
undidmsg = _("line wrap"); undidmsg = _("line wrap");
data = mallocstrncpy(NULL, f->data, u->begin); if (u->xflags & UNDO_SPLIT_MADENEW)
data[u->begin] = '\0'; prepend_wrap = TRUE;
free(f->data); do_wrap(f, TRUE);
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);
renumber(f); renumber(f);
break; break;
case UNSPLIT: case UNSPLIT:
...@@ -970,7 +963,7 @@ void update_undo(undo_type action) ...@@ -970,7 +963,7 @@ void update_undo(undo_type action)
/* Change to an add if we're not using the same undo struct /* Change to an add if we're not using the same undo struct
that we should be using */ that we should be using */
if (action != fs->last_action if (action != fs->last_action
|| (action != CUT && action != INSERT || (action != CUT && action != INSERT && action != SPLIT
&& openfile->current->lineno != fs->current_undo->lineno)) { && openfile->current->lineno != fs->current_undo->lineno)) {
add_undo(action); add_undo(action);
return; return;
...@@ -1087,7 +1080,7 @@ void wrap_reset(void) ...@@ -1087,7 +1080,7 @@ void wrap_reset(void)
/* We wrap the given line. Precondition: we assume the cursor has been /* We wrap the given line. Precondition: we assume the cursor has been
* moved forward since the last typed character. Return TRUE if we * moved forward since the last typed character. Return TRUE if we
* wrapped, and FALSE otherwise. */ * wrapped, and FALSE otherwise. */
bool do_wrap(filestruct *line) bool do_wrap(filestruct *line, bool undoing)
{ {
size_t line_len; size_t line_len;
/* The length of the line we wrap. */ /* The length of the line we wrap. */
...@@ -1152,6 +1145,7 @@ bool do_wrap(filestruct *line) ...@@ -1152,6 +1145,7 @@ bool do_wrap(filestruct *line)
return FALSE; return FALSE;
#ifndef NANO_TINY #ifndef NANO_TINY
if (!undoing)
add_undo(SPLIT); add_undo(SPLIT);
/* If autoindent is turned on, and we're on the character just after /* If autoindent is turned on, and we're on the character just after
...@@ -1248,6 +1242,8 @@ bool do_wrap(filestruct *line) ...@@ -1248,6 +1242,8 @@ bool do_wrap(filestruct *line)
null_at(&line->data, wrap_loc); null_at(&line->data, wrap_loc);
if (prepending) { if (prepending) {
if (!undoing)
update_undo(SPLIT);
/* If we're prepending, copy the text from the next line, minus /* If we're prepending, copy the text from the next line, minus
* the indentation that we already copied above. */ * the indentation that we already copied above. */
strcat(new_line, next_line); strcat(new_line, next_line);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment