tweaks: reshuffle some code to the one place that needs it

The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
This commit is contained in:
Benno Schulenberg
2019-05-30 16:37:16 +02:00
parent 6dc8570d55
commit 5a48edc9ae
5 changed files with 23 additions and 24 deletions

View File

@@ -462,7 +462,8 @@ bool open_buffer(const char *filename, bool new_buffer)
/* When not overriding an existing lock, discard the buffer. */
if (do_lockfile(realname) < 0) {
#ifdef ENABLE_MULTIBUFFER
close_buffer();
openfile = openfile->prev;
close_buffer(openfile->next);
#endif
free(realname);
return FALSE;
@@ -647,24 +648,12 @@ void switch_to_next_buffer(void)
switch_to_adjacent_buffer(FORWARD);
}
/* Delete the current entry from the circular list of open files,
* after switching to the buffer after it. */
void close_buffer(void)
/* Remove the given buffer from the circular list of buffers. */
void close_buffer(openfilestruct *buffer)
{
#ifdef ENABLE_HISTORIES
if (ISSET(POSITIONLOG) && !inhelp)
update_poshistory(openfile->filename,
openfile->current->lineno, xplustabs() + 1);
#endif
unlink_opennode(buffer);
switch_to_next_buffer();
/* Delete the old file buffer, and adjust the count in the top bar. */
unlink_opennode(openfile->prev);
if (!inhelp)
titlebar(NULL);
/* If now just one buffer remains open, show "Exit" in the help lines. */
/* When just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)
exitfunc->desc = exit_tag;
}