tweaks: really don't bother renumbering the lines in the cutbuffer

The lines from the cutbuffer will be renumbered when it matters: when
they get pasted.

The only place that used the numbering of (a copy of) the cutbuffer
(the updating of an undo item) already iterates through its lines.
Just add a counter there instead of making use of the line numbers.
master
Benno Schulenberg 2019-05-01 12:24:26 +02:00
parent 85fc41470b
commit 404a6862cd
2 changed files with 5 additions and 9 deletions

View File

@ -317,10 +317,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
if (cutbuffer == NULL) {
cutbuffer = openfile->filetop;
cutbottom = openfile->filebot;
renumber_from(cutbuffer);
} else {
linestruct *was_bottom = cutbottom;
/* Tack the data of the first line of the text onto the data of
* the last line in the given buffer. */
cutbottom->data = charealloc(cutbottom->data,
@ -339,8 +336,6 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
cutbottom->next->prev = cutbottom;
cutbottom = openfile->filebot;
}
renumber_from(was_bottom);
}
/* Since the text has now been saved, remove it from the file buffer. */

View File

@ -1371,13 +1371,14 @@ void update_undo(undo_type action)
u->xflags |= WAS_MARKED_FORWARD;
} else {
linestruct *bottomline = u->cutbuffer;
size_t count = 0;
/* Find the end of the cut for the undo/redo, using our copy. */
while (bottomline->next != NULL)
while (bottomline->next != NULL) {
bottomline = bottomline->next;
u->lineno = u->mark_begin_lineno + bottomline->lineno -
u->cutbuffer->lineno;
count++;
}
u->lineno = u->mark_begin_lineno + count;
if (ISSET(CUT_FROM_CURSOR) || u->type == CUT_TO_EOF) {
u->begin = strlen(bottomline->data);
if (u->lineno == u->mark_begin_lineno)