[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] feedback: upon first switch to a buffer, show its error mess
From: |
Benno Schulenberg |
Subject: |
[PATCH 2/2] feedback: upon first switch to a buffer, show its error message (if any) |
Date: |
Sat, 13 Mar 2021 14:32:41 +0100 |
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>
---
src/definitions.h | 2 ++
src/files.c | 8 ++++++++
src/winio.c | 6 ++++++
3 files changed, 16 insertions(+)
diff --git a/src/definitions.h b/src/definitions.h
index fe4403ef..3f2ef3e6 100644
--- a/src/definitions.h
+++ b/src/definitions.h
@@ -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;
diff --git a/src/files.c b/src/files.c
index 45f6bbd8..0b7f62a3 100644
--- a/src/files.c
+++ b/src/files.c
@@ -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);
diff --git a/src/winio.c b/src/winio.c
index cf7015c2..fa60d01f 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -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) {
--
2.29.3