diag: fix printing of snippets containing left brackets
This commit is contained in:
+10
-6
@@ -4,10 +4,10 @@
|
|||||||
#include "../write.h"
|
#include "../write.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <fx/core/stringstream.h>
|
#include <fx/core/stringstream.h>
|
||||||
#include <fx/term/print.h>
|
#include <fx/term/print.h>
|
||||||
#include <fx/term/tty.h>
|
#include <fx/term/tty.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <ivy/line-source.h>
|
#include <ivy/line-source.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -67,23 +67,23 @@ struct snippet_print_ctx {
|
|||||||
|
|
||||||
#define STREAM_COLOUR_ERROR_B(stream, str) \
|
#define STREAM_COLOUR_ERROR_B(stream, str) \
|
||||||
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
||||||
fx_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL); \
|
fx_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL); \
|
||||||
}
|
}
|
||||||
#define STREAM_COLOUR_WARN_B(stream, str) \
|
#define STREAM_COLOUR_WARN_B(stream, str) \
|
||||||
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
||||||
fx_stream_write_string(str, __STREAM_COLOUR_WARN, NULL); \
|
fx_stream_write_string(str, __STREAM_COLOUR_WARN, NULL); \
|
||||||
}
|
}
|
||||||
#define STREAM_COLOUR_HINT_B(stream, str) \
|
#define STREAM_COLOUR_HINT_B(stream, str) \
|
||||||
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
||||||
fx_stream_write_string(str, __STREAM_COLOUR_HINT, NULL); \
|
fx_stream_write_string(str, __STREAM_COLOUR_HINT, NULL); \
|
||||||
}
|
}
|
||||||
#define STREAM_COLOUR_ACCENT_B(stream, str) \
|
#define STREAM_COLOUR_ACCENT_B(stream, str) \
|
||||||
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
||||||
fx_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL); \
|
fx_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL); \
|
||||||
}
|
}
|
||||||
#define STREAM_COLOUR_RESET_B(stream, str) \
|
#define STREAM_COLOUR_RESET_B(stream, str) \
|
||||||
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
|
||||||
fx_stream_write_string(str, __STREAM_COLOUR_RESET, NULL); \
|
fx_stream_write_string(str, __STREAM_COLOUR_RESET, NULL); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_header(
|
static void print_header(
|
||||||
@@ -449,11 +449,15 @@ static void print_snippet(
|
|||||||
update_highlighting(&printer);
|
update_highlighting(&printer);
|
||||||
|
|
||||||
diag_stream_putc(stream, c);
|
diag_stream_putc(stream, c);
|
||||||
|
if (c == '[') {
|
||||||
|
diag_stream_putc(stream, c);
|
||||||
|
}
|
||||||
|
|
||||||
update_underline(&printer);
|
update_underline(&printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
diag_stream_putc(stream, '\n');
|
diag_stream_putc(stream, '\n');
|
||||||
|
|
||||||
write_underline(&printer);
|
write_underline(&printer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user