Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion ide/src/FailureComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Highlight
editor={ed}
from={from}
to={to}
color={color}
key={to.line * 13 + to.ch}
/>
);
});
return (
<>
{`line ${failure.loc['start-line']}`}
{locs}
</>
);
}
return (
<>
Expand Down