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. */
#endif
#ifdef ENABLE_MULTIBUFFER
char *errormessage;
/* The ALERT message (if any) that occurred when opening the file. */
struct openfilestruct *next;
/* The next open file, if any. */
struct openfilestruct *prev;

View File

@ -92,6 +92,8 @@ void make_new_buffer(void)
openfile->statinfo = NULL;
openfile->lock_filename = NULL;
openfile->errormessage = NULL;
#endif
#ifdef ENABLE_COLOR
openfile->syntax = NULL;
@ -558,6 +560,11 @@ void redecorate_after_switch(void)
/* Prevent a possible Shift selection from getting cancelled. */
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. */
mention_name_and_linecount();
}
@ -595,6 +602,7 @@ void close_buffer(void)
/* Free the undo stack. */
discard_until(NULL);
#endif
free(orphan->errormessage);
openfile = orphan->prev;
free(orphan);

View File

@ -2229,6 +2229,12 @@ void statusline(message_type importance, const char *msg, ...)
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, 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 (lastmessage == ALERT) {
if (start_col > 4) {