From 2e03fc91b6962f93b3a84bc69b3ec52377de7e17 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 5 Mar 2019 21:15:24 +0100 Subject: [PATCH] vala: Output multiline source-reference Fixes https://gitlab.gnome.org/GNOME/vala/issues/764 --- vala/valareport.vala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vala/valareport.vala b/vala/valareport.vala index 0aad89f15..8e480f03d 100644 --- a/vala/valareport.vala +++ b/vala/valareport.vala @@ -233,19 +233,29 @@ public class Vala.Report { */ private void report_source (SourceReference source) { if (source.begin.line != source.end.line) { - // FIXME Cannot report multi-line issues currently + int idx; + for (idx = source.begin.line - 2; idx < source.end.line + 2; ++idx) { + string offending_line = source.file.get_source_line (idx); + if (source.begin.line <= idx <= source.end.line) { + stderr.puts (caret_color_start); + stderr.printf (" >"); + stderr.puts (caret_color_end); + } + stderr.printf (" %s\n", offending_line); + } return; } string offending_line = source.file.get_source_line (source.begin.line); if (offending_line != null) { - stderr.printf ("%s\n", offending_line); + stderr.printf (" %s\n", offending_line); int idx; /* We loop in this manner so that we don't fall over on differing * tab widths. This means we get the ^s in the right places. */ + stderr.printf (" "); for (idx = 1; idx < source.begin.column; ++idx) { if (offending_line[idx - 1] == '\t') { stderr.printf ("\t"); -- 2.47.2