Letting also unlink_node() update 'filebot', instead of doing it in

four different places.  It is not a problem that the history routines
also use these functions, as history nodes will never equal filebot.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2015-12-08 16:02:05 +00:00
parent 77c0357868
commit a64bfbee8b
3 changed files with 9 additions and 13 deletions

View File

@ -1,6 +1,6 @@
2015-12-08 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (splice_node): Make this function update 'filebot',
instead of doing it in four different places.
* src/nano.c (splice_node, unlink_node): Let these functions update
'filebot', instead of doing it in four different places each.
2015-12-07 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Quit the loop when there is no end match.

View File

@ -110,7 +110,7 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
openfile->filebot = newnode;
}
/* Unlink a node from the rest of the filestruct and delete it. */
/* Disconnect a node from a linked list of filestructs and delete it. */
void unlink_node(filestruct *fileptr)
{
assert(fileptr != NULL);
@ -120,10 +120,14 @@ void unlink_node(filestruct *fileptr)
if (fileptr->next != NULL)
fileptr->next->prev = fileptr->prev;
/* Update filebot when removing a node at the end of file. */
if (openfile && openfile->filebot == fileptr)
openfile->filebot = fileptr->prev;
delete_node(fileptr);
}
/* Delete a node from the filestruct. */
/* Free the data structures in the given node. */
void delete_node(filestruct *fileptr)
{
assert(fileptr != NULL && fileptr->data != NULL);

View File

@ -144,8 +144,6 @@ void do_deletion(undo_type action)
openfile->mark_begin_x += openfile->current_x;
}
#endif
if (openfile->filebot == foo)
openfile->filebot = openfile->current;
unlink_node(foo);
renumber(openfile->current);
@ -566,8 +564,6 @@ void do_undo(void)
f->data = charealloc(f->data, strlen(f->data) +
strlen(&f->next->data[u->mark_begin_x]) + 1);
strcat(f->data, &f->next->data[u->mark_begin_x]);
if (openfile->filebot == f->next)
openfile->filebot = f;
unlink_node(f->next);
goto_line_posx(u->lineno, u->begin);
break;
@ -707,8 +703,6 @@ void do_redo(void)
}
f->data = charealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
strcat(f->data, u->strdata);
if (f->next == openfile->filebot)
openfile->filebot = f;
unlink_node(f->next);
renumber(f);
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
@ -2098,11 +2092,9 @@ void do_justify(bool full_justify)
strcat(openfile->current->data, next_line->data +
indent_len);
/* Don't destroy edittop or filebot! */
/* Don't destroy edittop! */
if (next_line == openfile->edittop)
openfile->edittop = openfile->current;
if (next_line == openfile->filebot)
openfile->filebot = openfile->current;
#ifndef NANO_TINY
/* Adjust the mark coordinates to compensate for the change