Skip to content

Commit 5ec4a65

Browse files
fix highlighter issue
1 parent 5e7a3a4 commit 5ec4a65

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

packages/react/src/components/DiffView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
22
/* eslint-disable @typescript-eslint/ban-ts-comment */
3-
import { DiffFile, _cacheMap, SplitSide } from "@git-diff-view/core";
3+
import { DiffFile, _cacheMap, SplitSide, highlighter as buildInHighlighter } from "@git-diff-view/core";
44
import { diffFontSizeName, DiffModeEnum } from "@git-diff-view/utils";
55
import { memo, useEffect, useMemo, forwardRef, useImperativeHandle, useRef } from "react";
66
import * as React from "react";
@@ -324,7 +324,10 @@ const DiffViewWithRef = <T extends unknown>(
324324
diffFile.initSyntax({ registerHighlighter: registerHighlighter });
325325
diffFile.notifyAll();
326326
}
327-
} else if (diffFile._getHighlighterType() !== "class") {
327+
} else if (
328+
diffFile._getHighlighterName() !== buildInHighlighter.name ||
329+
diffFile._getHighlighterType() !== "class"
330+
) {
328331
diffFile.initSyntax();
329332
diffFile.notifyAll();
330333
}

packages/solid/src/components/DiffView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
2-
import { _cacheMap, DiffFile, SplitSide } from "@git-diff-view/core";
2+
import { _cacheMap, DiffFile, SplitSide, highlighter as buildInHighlighter } from "@git-diff-view/core";
33
import { diffFontSizeName, DiffModeEnum } from "@git-diff-view/utils";
44
import { type JSXElement, type JSX, createSignal, createEffect, createMemo, onCleanup, Show } from "solid-js";
55

@@ -206,7 +206,10 @@ const InternalDiffView = <T extends unknown>(props: DiffViewProps<T>) => {
206206
currentDiffFile.initSyntax({ registerHighlighter: registerHighlighter });
207207
currentDiffFile.notifyAll();
208208
}
209-
} else if (currentDiffFile._getHighlighterType() !== "class") {
209+
} else if (
210+
currentDiffFile._getHighlighterName() !== buildInHighlighter.name ||
211+
currentDiffFile._getHighlighterType() !== "class"
212+
) {
210213
currentDiffFile.initSyntax();
211214
currentDiffFile.notifyAll();
212215
}

packages/svelte/src/lib/components/DiffView.svelte

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@
115115
116116
let wrapperRef = $state<HTMLElement | null>(null);
117117
118-
const setWidget = (v: { side?: SplitSide; lineNumber?: number }) => {
119-
if (props) widgetState.side = v.side;
120-
widgetState.lineNumber = v.lineNumber;
121-
};
122-
123118
const enableHighlight = $derived(props.diffViewHighlight ?? true);
124119
125120
const theme = $derived(props.diffViewTheme);
@@ -179,7 +174,10 @@
179174
});
180175
diffFile.notifyAll();
181176
}
182-
} else if (diffFile._getHighlighterType() !== 'class') {
177+
} else if (
178+
diffFile._getHighlighterName() !== buildInHighlighter.name ||
179+
diffFile._getHighlighterType() !== 'class'
180+
) {
183181
diffFile.initSyntax();
184182
diffFile.notifyAll();
185183
}

packages/vue/src/components/DiffView.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DiffFile, _cacheMap, SplitSide } from "@git-diff-view/core";
1+
import { DiffFile, _cacheMap, SplitSide, highlighter as buildInHighlighter } from "@git-diff-view/core";
22
import { diffFontSizeName, DiffModeEnum } from "@git-diff-view/utils";
33
import { defineComponent, provide, ref, watch, watchEffect, computed, onUnmounted } from "vue";
44

@@ -174,10 +174,13 @@ export const DiffView = defineComponent<
174174
registerHighlighter: registerHighlighter,
175175
});
176176
instance.notifyAll();
177-
} else if (instance._getHighlighterType() !== "class") {
178-
instance.initSyntax({});
179-
instance.notifyAll();
180177
}
178+
} else if (
179+
instance._getHighlighterName() !== buildInHighlighter.name ||
180+
instance._getHighlighterType() !== "class"
181+
) {
182+
instance.initSyntax({});
183+
instance.notifyAll();
181184
}
182185
}
183186
};

0 commit comments

Comments
 (0)