Skip to content

Commit

Permalink
fix overlapping highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 authored and calyptobai committed Aug 2, 2023
1 parent c16b10d commit 9022665
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/src/components/CodeBlock/CodeFull/CodeContainerFull.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ const CodeContainerFull = ({
return (
<div ref={ref} className="relative pb-44">
{tokens.map((line, index) => {
let highlightForLine = highlights?.findIndex(
(h) => h && index >= h.lines[0] && index <= h.lines[1],
);
let highlightForLine = highlights
?.sort((a, b) =>
a &&
b &&
a?.lines?.[1] - a?.lines?.[0] < b?.lines?.[1] - b?.lines?.[0]
? -1
: 1,
)
.findIndex((h) => h && index >= h.lines[0] && index <= h.lines[1]);
if (highlightForLine && highlightForLine < 0) {
highlightForLine = undefined;
}
Expand Down

0 comments on commit 9022665

Please sign in to comment.