* src/text.c (do_undo): Adjust whitespace after the previous change.
* src/text.c (add_undo): Elide an unneeded variable and correct two
comments. And try to put the more frequent condition first.
+ * src/text.c (add_undo): Rename the parameter 'current_action' to
+ 'action', to match the other functions.
2015-06-14 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Add some debugging code to track which
void remove_magicline(void);
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
-void add_undo(undo_type current_action);
+void add_undo(undo_type action);
void update_undo(undo_type action);
#endif
size_t get_totsize(const filestruct *begin, const filestruct *end);
}
/* Add a new undo struct to the top of the current pile. */
-void add_undo(undo_type current_action)
+void add_undo(undo_type action)
{
openfilestruct *fs = openfile;
undo *u = fs->current_undo;
/* 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 == fs->current->lineno &&
- ((current_action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x) ||
- (current_action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer())))
+ ((action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x) ||
+ (action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer())))
return;
/* When trying to delete the final newline, don't add an undo for it. */
- if (current_action == DEL && openfile->current->next == openfile->filebot &&
+ if (action == DEL && openfile->current->next == openfile->filebot &&
openfile->current->data[openfile->current_x] == '\0' &&
openfile->current_x != 0 && !ISSET(NO_NEWLINES))
return;
/* Allocate and initialize a new undo type. */
u = (undo *) nmalloc(sizeof(undo));
- u->type = current_action;
+ u->type = action;
u->lineno = fs->current->lineno;
u->begin = fs->current_x;
#ifndef DISABLE_WRAPPING
}
u->strdata = mallocstrcpy(NULL, fs->current->next->data);
}
- current_action = u->type = JOIN;
+ action = u->type = JOIN;
break;
#ifndef DISABLE_WRAPPING
case SPLIT_BEGIN:
- current_action = fs->undotop->type;
+ action = fs->undotop->type;
break;
case SPLIT_END:
break;
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n",
- fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, current_action);
+ fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, action);
fprintf(stderr, "left add_undo...\n");
#endif
- fs->last_action = current_action;
+ fs->last_action = action;
}
/* Update an undo item, or determine whether a new one is really needed