|
1 | | -import { SplitSide, disableCache } from "@git-diff-view/react"; |
| 1 | +import { SplitSide, disableCache, highlighter as buildInHighlighter } from "@git-diff-view/react"; |
2 | 2 | import { Box, Button, Card, CloseButton, Group, Stack, useMantineColorScheme, Text } from "@mantine/core"; |
3 | 3 | import { usePrevious } from "@mantine/hooks"; |
4 | 4 | import { memo, useEffect, useState } from "react"; |
@@ -35,23 +35,17 @@ export const MainContentDiffExampleView = memo( |
35 | 35 |
|
36 | 36 | const { highlight, mode, wrap, engine, tabSpace, fastDiff, autoExpandCommentLine } = useDiffConfig(); |
37 | 37 |
|
38 | | - const prevEngine = usePrevious(engine); |
39 | | - |
40 | 38 | const prevTabSpace = usePrevious(tabSpace); |
41 | 39 |
|
42 | 40 | const prevFastDiff = usePrevious(fastDiff); |
43 | 41 |
|
44 | 42 | const prevAutoExpandCommentLine = usePrevious(autoExpandCommentLine); |
45 | 43 |
|
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 |
50 | 44 | useEffect(() => { |
51 | 45 | if (tabSpace !== prevTabSpace || fastDiff !== prevFastDiff) { |
52 | 46 | refreshDiffFile(); |
53 | 47 | } |
54 | | - }, [engine, prevEngine, tabSpace, prevTabSpace, fastDiff, prevFastDiff, refreshDiffFile]); |
| 48 | + }, [tabSpace, prevTabSpace, fastDiff, prevFastDiff, refreshDiffFile]); |
55 | 49 |
|
56 | 50 | useEffect(() => { |
57 | 51 | if (autoExpandCommentLine !== prevAutoExpandCommentLine) { |
@@ -139,7 +133,7 @@ export const MainContentDiffExampleView = memo( |
139 | 133 | </Box> |
140 | 134 | ); |
141 | 135 | }} |
142 | | - registerHighlighter={engine === "lowlight" ? undefined : highlighter} |
| 136 | + registerHighlighter={engine === "lowlight" ? buildInHighlighter : highlighter} |
143 | 137 | diffViewFontSize={13} |
144 | 138 | /> |
145 | 139 | </Box> |
|
0 commit comments