nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 404a6862cdace77172f44009c6f154b5c3302500
parent 85fc41470be84b3cb449197a4562fc17656232f9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  1 May 2019 12:24:26 +0200

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.

Diffstat:
Msrc/nano.c | 5-----
Msrc/text.c | 9+++++----
2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -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. */ diff --git a/src/text.c b/src/text.c @@ -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)