commit 4c53e2f56bac789d471dd468bd7353173d5a6f40
parent 14140d5249680f350146b6a7a488e6215c307fce
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 30 Apr 2019 12:15:50 +0200
tweaks: elide two unneeded variables
After extracting a line or region, the current line is always the one
where renumbering should start. And when ingrafting a buffer, it is
always the first ingrafted line where renumbering should start. The
'top_save' variable was indirectly getting set to those lines.
Also, renumber immediately after unpartitioning the file buffer, before
doing anything else.
Diffstat:
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -280,7 +280,6 @@ void unpartition_buffer(partition **p)
void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
{
- linestruct *top_save;
bool edittop_inside;
#ifndef NANO_TINY
bool mark_inside = FALSE;
@@ -359,12 +358,12 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
openfile->mark = openfile->current;
#endif
- top_save = openfile->filetop;
-
/* Unpartition the buffer so that it contains all the text
* again, minus the saved text. */
unpartition_buffer(&filepart);
+ renumber_from(openfile->current);
+
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
if (edittop_inside) {
@@ -372,9 +371,6 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
refresh_needed = TRUE;
}
- /* Renumber, starting with the beginning line of the old partition. */
- renumber_from(top_save);
-
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
@@ -384,7 +380,6 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
* at the current cursor position. */
void ingraft_buffer(linestruct *somebuffer)
{
- linestruct *top_save;
size_t current_x_save = openfile->current_x;
bool edittop_inside;
#ifndef NANO_TINY
@@ -442,14 +437,11 @@ void ingraft_buffer(linestruct *somebuffer)
if (edittop_inside)
openfile->edittop = openfile->filetop;
- top_save = openfile->filetop;
-
/* Unpartition the buffer so that it contains all the text
* again, plus the copied text. */
unpartition_buffer(&filepart);
- /* Renumber, starting with the beginning line of the old partition. */
- renumber_from(top_save);
+ renumber_from(somebuffer);
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')