From fe3de74620abfc0e8d802db024c3680fc68f71d8 Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 30 May 2022 16:08:59 +0200 Subject: [PATCH] clay: render syntax errors at end of file Previously, if the pointer for a syntax error pointed to the end of the file (and the file ended in a newline) the code snippet rendering would try to display a line _beyond_ the end of the file, causing a crash. Here, we detect that case, and display `<>` instead. (Originally merged through #5812, but got lost somewhere along the way.) Fixes #6287. --- pkg/arvo/sys/vane/clay.hoon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index b9c677a53..bb2c2bd57 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -964,8 +964,14 @@ %- mean %- flop =/ lyn p.hair =/ col q.hair + ^- (list tank) :~ leaf+"syntax error at [{} {}] in {}" - leaf+(trip (snag (dec lyn) (to-wain:format (crip tex)))) + :: + =/ =wain (to-wain:format (crip tex)) + ?: (gth lyn (lent wain)) + '<>' + (snag (dec lyn) wain) + :: leaf+(runt [(dec col) '-'] "^") == ::