commit 9bf57e5ca086b38188d6586388e9ed626053daf8
parent f9103a5cb57296ddfaa44e737e1b59a2e20be14e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 3 Mar 2018 21:23:02 +0100
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().
Diffstat:
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git 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;