From db229a6c4a7df5cba5b0207b52fa23021f34e365 Mon Sep 17 00:00:00 2001 From: Adam Solove Date: Sat, 31 Dec 2022 15:24:03 -0500 Subject: [PATCH] Try to highlight errors in anchor source. --- ide/src/FailureComponent.tsx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ide/src/FailureComponent.tsx b/ide/src/FailureComponent.tsx index 04fbb0495..e6a2db143 100644 --- a/ide/src/FailureComponent.tsx +++ b/ide/src/FailureComponent.tsx @@ -94,7 +94,38 @@ function FailureComponentUnconnected({ ); } if (id && failure.loc.source.includes(id)) { - return <>this message; + // Referring to a loc in this message + const rainbow = ['#fcc', '#fda', '#cff', '#cfc', '#ccf', '#faf', '#fdf']; + const color = rainbow[0 % rainbow.length]; + const calculated = [failure.loc].map((loc) => { + const { from, to } = srclocToCodeMirrorPosition(loc); + const chunk = chunks.find((c) => loc.source.includes(c.id)); + if (chunk !== undefined && isInitializedEditor(chunk.editor)) { + return { from, to, editor: chunk.editor }; + } + return undefined; + }); + const locs = calculated.map((attributes) => { + if (attributes === undefined) { + return <>; + } + const { editor: ed, from, to } = attributes; + return ( + + ); + }); + return ( + <> + {`line ${failure.loc['start-line']}`} + {locs} + + ); } return ( <>