Problem
When one line contains several small insertions, the inline highlight renders everything between the first and the last change as a single block instead of highlighting each change separately. This is especially visible for text without word boundaries (e.g. CJK text):
old: |原画= 作画:スタジオA、金田B、長崎C
new: |原画= 作画:スタジオA[アA]、金田B[カB]、長崎C[ナC]
Actual: one highlight span [アA]、金田B[カB]、長崎C[ナC].
Expected: three separate spans [アA], [カB], [ナC].
Root cause
diffChanges in packages/core/src/parse/change-range.ts calls fastDiff(delString, addString, 0, true). The hardcoded cleanup=true runs diff-match-patch semantic cleanup, which absorbs small equalities (like the 、 separators) into the surrounding edits.
Repro (node, @git-diff-view/file):
import { diffChanges } from "@git-diff-view/file";
const r = diffChanges({ text: newText } as any, { text: oldText } as any);
console.log(JSON.stringify(r.addRange.range));
// single INSERT "[アA]、金田B[カB]、長崎C[ナC]" instead of three INSERTs
Suggestion
Add an opt-out flag following the existing config convention in the same file (e.g. setEnableDiffSemanticCleanup, default true), and make the prebuilt fast-diff template survive rendering when setEnableFastDiffTemplate(true) is set (currently getPlainDiffTemplate/getSyntaxDiffTemplate always rebuild the single-span template, so the flag has no visible effect).
Happy to send a PR with the above.
Problem
When one line contains several small insertions, the inline highlight renders everything between the first and the last change as a single block instead of highlighting each change separately. This is especially visible for text without word boundaries (e.g. CJK text):
Actual: one highlight span
[アA]、金田B[カB]、長崎C[ナC].Expected: three separate spans
[アA],[カB],[ナC].Root cause
diffChangesinpackages/core/src/parse/change-range.tscallsfastDiff(delString, addString, 0, true). The hardcodedcleanup=trueruns diff-match-patch semantic cleanup, which absorbs small equalities (like the、separators) into the surrounding edits.Repro (node,
@git-diff-view/file):Suggestion
Add an opt-out flag following the existing config convention in the same file (e.g.
setEnableDiffSemanticCleanup, defaulttrue), and make the prebuilt fast-diff template survive rendering whensetEnableFastDiffTemplate(true)is set (currentlygetPlainDiffTemplate/getSyntaxDiffTemplatealways rebuild the single-span template, so the flag has no visible effect).Happy to send a PR with the above.