feedback: upon first switch to a buffer, show its error message (if any)

When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
master
Benno Schulenberg 2021-03-13 12:08:47 +01:00
parent e8db390d6f
commit ede64d7ea0
3 changed files with 16 additions and 0 deletions

View File

@ -567,6 +567,8 @@ typedef struct openfilestruct {
/* The syntax that applies to this file, if any. */ /* The syntax that applies to this file, if any. */
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
char *errormessage;
/* The ALERT message (if any) that occurred when opening the file. */
struct openfilestruct *next; struct openfilestruct *next;
/* The next open file, if any. */ /* The next open file, if any. */
struct openfilestruct *prev; struct openfilestruct *prev;

View File

@ -92,6 +92,8 @@ void make_new_buffer(void)
openfile->statinfo = NULL; openfile->statinfo = NULL;
openfile->lock_filename = NULL; openfile->lock_filename = NULL;
openfile->errormessage = NULL;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
openfile->syntax = NULL; openfile->syntax = NULL;
@ -558,6 +560,11 @@ void redecorate_after_switch(void)
/* Prevent a possible Shift selection from getting cancelled. */ /* Prevent a possible Shift selection from getting cancelled. */
shift_held = TRUE; shift_held = TRUE;
if (openfile->errormessage) {
statusline(ALERT, openfile->errormessage);
free(openfile->errormessage);
openfile->errormessage = NULL;
} else
/* Indicate on the status bar where we switched to. */ /* Indicate on the status bar where we switched to. */
mention_name_and_linecount(); mention_name_and_linecount();
} }
@ -595,6 +602,7 @@ void close_buffer(void)
/* Free the undo stack. */ /* Free the undo stack. */
discard_until(NULL); discard_until(NULL);
#endif #endif
free(orphan->errormessage);
openfile = orphan->prev; openfile = orphan->prev;
free(orphan); free(orphan);

View File

@ -2229,6 +2229,12 @@ void statusline(message_type importance, const char *msg, ...)
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap); vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
va_end(ap); va_end(ap);
#ifdef ENABLE_MULTIBUFFER
if (!we_are_running && importance == ALERT &&
!openfile->errormessage && openfile->next != openfile)
openfile->errormessage = copy_of(compound);
#endif
/* If there are multiple alert messages, add trailing dots to the first. */ /* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == ALERT) { if (lastmessage == ALERT) {
if (start_col > 4) { if (start_col > 4) {