From 9bf57e5ca086b38188d6586388e9ed626053daf8 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 3 Mar 2018 21:23:02 +0100 Subject: [PATCH] tweaks: do not needlessly renumber the lines in the buffer For cuts, pastes, and inserts, the lines have already been renumbered; for indents, comments, and replacements, the line numbers cannot have changed. (And anyway, variable 'f' is not set for those cases.) Only when lines get split (ENTER) or fused together (JOIN) do the later lines need to be renumbered. This mirrors what is done for do_redo(). --- src/text.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/text.c b/src/text.c index 9ef0f86d..158d9508 100644 --- a/src/text.c +++ b/src/text.c @@ -732,7 +732,6 @@ void do_undo(void) while (openfile->current_undo->type != SPLIT_BEGIN) do_undo(); u = openfile->current_undo; - f = openfile->current; case SPLIT_BEGIN: undidmsg = _("text add"); break; @@ -753,18 +752,17 @@ void do_undo(void) free(f->data); f->data = data; splice_node(f, t); + renumber(t); goto_line_posx(u->lineno, u->begin); break; case CUT_TO_EOF: case CUT: undidmsg = _("text cut"); undo_cut(u); - f = fsfromline(u->lineno); break; case PASTE: undidmsg = _("text uncut"); undo_paste(u); - f = fsfromline(u->mark_begin_lineno); break; case ENTER: if (f->next == NULL) { @@ -778,6 +776,7 @@ void do_undo(void) strlen(&u->strdata[from_x]) + 1); strcat(f->data, &u->strdata[from_x]); unlink_node(f->next); + renumber(f); goto_line_posx(u->lineno, to_x); break; case INDENT: @@ -829,8 +828,6 @@ void do_undo(void) if (undidmsg && !pletion_line) statusline(HUSH, _("Undid action (%s)"), undidmsg); - renumber(f); - openfile->current_undo = openfile->current_undo->next; openfile->last_action = OTHER; openfile->mark = NULL;