Skip to content

Commit 67c269d

Browse files
update
1 parent 03fc04f commit 67c269d

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

ui/react-example/src/components/MainContent/MainContentDiffExampleView.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SplitSide, disableCache } from "@git-diff-view/react";
1+
import { SplitSide, disableCache, highlighter as buildInHighlighter } from "@git-diff-view/react";
22
import { Box, Button, Card, CloseButton, Group, Stack, useMantineColorScheme, Text } from "@mantine/core";
33
import { usePrevious } from "@mantine/hooks";
44
import { memo, useEffect, useState } from "react";
@@ -35,23 +35,17 @@ export const MainContentDiffExampleView = memo(
3535

3636
const { highlight, mode, wrap, engine, tabSpace, fastDiff, autoExpandCommentLine } = useDiffConfig();
3737

38-
const prevEngine = usePrevious(engine);
39-
4038
const prevTabSpace = usePrevious(tabSpace);
4139

4240
const prevFastDiff = usePrevious(fastDiff);
4341

4442
const prevAutoExpandCommentLine = usePrevious(autoExpandCommentLine);
4543

46-
// because of the cache, switch the highlighter engine will not work, need a new diffFile instance to avoid this
47-
// see packages/core/src/file.ts:172 getFile
48-
// TODO fix this in the future
49-
// fixed
5044
useEffect(() => {
5145
if (tabSpace !== prevTabSpace || fastDiff !== prevFastDiff) {
5246
refreshDiffFile();
5347
}
54-
}, [engine, prevEngine, tabSpace, prevTabSpace, fastDiff, prevFastDiff, refreshDiffFile]);
48+
}, [tabSpace, prevTabSpace, fastDiff, prevFastDiff, refreshDiffFile]);
5549

5650
useEffect(() => {
5751
if (autoExpandCommentLine !== prevAutoExpandCommentLine) {
@@ -139,7 +133,7 @@ export const MainContentDiffExampleView = memo(
139133
</Box>
140134
);
141135
}}
142-
registerHighlighter={engine === "lowlight" ? undefined : highlighter}
136+
registerHighlighter={engine === "lowlight" ? buildInHighlighter : highlighter}
143137
diffViewFontSize={13}
144138
/>
145139
</Box>

0 commit comments

Comments
 (0)