11import { diffChanges , relativeChanges } from "./change-range" ;
2- import { DiffLineType } from "./diff-line" ;
2+ import { DiffLineType , DiffLine } from "./diff-line" ;
33import { DiffHunkExpansionType } from "./raw-diff" ;
44import {
55 getEnableFastDiffTemplate ,
@@ -10,7 +10,6 @@ import {
1010} from "./template" ;
1111
1212import type { SyntaxLineWithTemplate } from "../file" ;
13- import type { DiffLine } from "./diff-line" ;
1413import type { DiffHunk , DiffHunkHeader } from "./raw-diff" ;
1514
1615/** How many new lines will be added to a diff hunk by default. */
@@ -122,8 +121,14 @@ export const getDiffRange = (
122121 if ( ! addition . changes || ! deletion . changes ) {
123122 // use the original text content to computed diff range
124123 // fix: get diff with ignoreWhiteSpace config
125- const _addition = addition . clone ( getAdditionRaw ( addition . newLineNumber ) || addition . text || "" ) ;
126- const _deletion = deletion . clone ( getDeletionRaw ( deletion . oldLineNumber ) || deletion . text || "" ) ;
124+ const _addition = DiffLine . prototype . clone . call (
125+ addition ,
126+ getAdditionRaw ( addition . newLineNumber ) || addition . text || ""
127+ ) ;
128+ const _deletion = DiffLine . prototype . clone . call (
129+ deletion ,
130+ getDeletionRaw ( deletion . oldLineNumber ) || deletion . text || ""
131+ ) ;
127132 const { addRange, delRange } = relativeChanges ( _addition , _deletion ) ;
128133 addition . changes = addRange ;
129134 deletion . changes = delRange ;
@@ -154,8 +159,14 @@ export const getDiffRange = (
154159 } ) ;
155160 }
156161 } else {
157- const _addition = addition . clone ( getAdditionRaw ( addition . newLineNumber ) || addition . text || "" ) ;
158- const _deletion = deletion . clone ( getDeletionRaw ( deletion . oldLineNumber ) || deletion . text || "" ) ;
162+ const _addition = DiffLine . prototype . clone . call (
163+ addition ,
164+ getAdditionRaw ( addition . newLineNumber ) || addition . text || ""
165+ ) ;
166+ const _deletion = DiffLine . prototype . clone . call (
167+ deletion ,
168+ getDeletionRaw ( deletion . oldLineNumber ) || deletion . text || ""
169+ ) ;
159170 const { addRange, delRange } = diffChanges ( _addition , _deletion ) ;
160171 addition . diffChanges = addRange ;
161172 deletion . diffChanges = delRange ;
0 commit comments