diff options
Diffstat (limited to 'core/Messages.zig')
| -rw-r--r-- | core/Messages.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 4dd39097..5a36e166 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -433,8 +433,9 @@ pub fn ink(chrome: *const pardes.colors.ChromeTheme, kind: Kind) [3]u8 { /// The places a compiler's report names put on `s`: each /// `path:line:col: error|warning|note: words` row (a relative path is -/// `dir`'s), its words there, and the rows after the first error, up to -/// the next place, its detail. How many it found; none without an error. +/// `dir`'s), its words there, each place once, and the rows after the +/// first error, up to the next place, its detail. How many it found; none +/// without an error. pub fn readPlaces(s: *Said, dir: []const u8, rows: []const []const u8) usize { var errors: usize = 0; var detailing = false; @@ -458,6 +459,11 @@ pub fn readPlaces(s: *Said, dir: []const u8, rows: []const []const u8) usize { const place = &s.places[s.places_len]; place.* = .{ .line = found.line, .col = found.col }; if (std.Io.Dir.path.isAbsolute(found.path)) place.path.set(found.path) else _ = place.path.print("{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), found.path }); + // A place named again (a note at its error's) is not a second one. + const named = for (s.places[0..s.places_len]) |*was| { + if (was.line == place.line and was.col == place.col and std.mem.eql(u8, was.path.slice(), place.path.slice())) break true; + } else false; + if (named) continue; place.text.set(if (std.mem.startsWith(u8, found.text, "error: ")) found.text["error: ".len..] else found.text); s.places_len += 1; } |
