Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed May 19, 2024
1 parent f530bed commit dea6690
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/renderers/regex/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ const CSSHighlighter = memo(
useIsomorphicLayoutEffect(() => {
const el = ref.current!.firstChild!;

const highlights = regexes.flatMap((r, i) => {
const highlight = new Highlight(
const highlights = regexes.flatMap((r) => {
return new Highlight(
...execReg(r, value).map((m) => {
const start = m.index;
const end = m.index + m[0]!.length;
Expand All @@ -135,8 +135,10 @@ const CSSHighlighter = memo(
return range;
})
);
CSS.highlights.set(createCSSHighlightID(i), highlight);
return highlight;
});

highlights.forEach((h, i) => {
CSS.highlights.set(createCSSHighlightID(i), h);
});

return () => {
Expand Down

0 comments on commit dea6690

Please sign in to comment.