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.master
parent
14140d5249
commit
4c53e2f56b
14
src/nano.c
14
src/nano.c
|
@ -280,7 +280,6 @@ void unpartition_buffer(partition **p)
|
||||||
void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
|
void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
|
||||||
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
||||||
{
|
{
|
||||||
linestruct *top_save;
|
|
||||||
bool edittop_inside;
|
bool edittop_inside;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
bool mark_inside = FALSE;
|
bool mark_inside = FALSE;
|
||||||
|
@ -359,12 +358,12 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
|
||||||
openfile->mark = openfile->current;
|
openfile->mark = openfile->current;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
top_save = openfile->filetop;
|
|
||||||
|
|
||||||
/* Unpartition the buffer so that it contains all the text
|
/* Unpartition the buffer so that it contains all the text
|
||||||
* again, minus the saved text. */
|
* again, minus the saved text. */
|
||||||
unpartition_buffer(&filepart);
|
unpartition_buffer(&filepart);
|
||||||
|
|
||||||
|
renumber_from(openfile->current);
|
||||||
|
|
||||||
/* If the top of the edit window was inside the old partition, put
|
/* If the top of the edit window was inside the old partition, put
|
||||||
* it in range of current. */
|
* it in range of current. */
|
||||||
if (edittop_inside) {
|
if (edittop_inside) {
|
||||||
|
@ -372,9 +371,6 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
|
||||||
refresh_needed = TRUE;
|
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 the text doesn't end with a newline, and it should, add one. */
|
||||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
||||||
new_magicline();
|
new_magicline();
|
||||||
|
@ -384,7 +380,6 @@ void extract_buffer(linestruct **buffer_top, linestruct **buffer_bot,
|
||||||
* at the current cursor position. */
|
* at the current cursor position. */
|
||||||
void ingraft_buffer(linestruct *somebuffer)
|
void ingraft_buffer(linestruct *somebuffer)
|
||||||
{
|
{
|
||||||
linestruct *top_save;
|
|
||||||
size_t current_x_save = openfile->current_x;
|
size_t current_x_save = openfile->current_x;
|
||||||
bool edittop_inside;
|
bool edittop_inside;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -442,14 +437,11 @@ void ingraft_buffer(linestruct *somebuffer)
|
||||||
if (edittop_inside)
|
if (edittop_inside)
|
||||||
openfile->edittop = openfile->filetop;
|
openfile->edittop = openfile->filetop;
|
||||||
|
|
||||||
top_save = openfile->filetop;
|
|
||||||
|
|
||||||
/* Unpartition the buffer so that it contains all the text
|
/* Unpartition the buffer so that it contains all the text
|
||||||
* again, plus the copied text. */
|
* again, plus the copied text. */
|
||||||
unpartition_buffer(&filepart);
|
unpartition_buffer(&filepart);
|
||||||
|
|
||||||
/* Renumber, starting with the beginning line of the old partition. */
|
renumber_from(somebuffer);
|
||||||
renumber_from(top_save);
|
|
||||||
|
|
||||||
/* If the text doesn't end with a newline, and it should, add one. */
|
/* If the text doesn't end with a newline, and it should, add one. */
|
||||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
||||||
|
|
Loading…
Reference in New Issue