@@ -34,14 +34,9 @@ export function fnv1a32(
3434}
3535
3636function buildPatchCacheKey ( patch : string , scope = "diff-panel" ) : string {
37- const normalizedPatch = patch . trim ( ) ;
38- const primary = fnv1a32 ( normalizedPatch , FNV_OFFSET_BASIS_32 , FNV_PRIME_32 ) . toString ( 36 ) ;
39- const secondary = fnv1a32 (
40- normalizedPatch ,
41- SECONDARY_HASH_SEED ,
42- SECONDARY_HASH_MULTIPLIER ,
43- ) . toString ( 36 ) ;
44- return `${ scope } :${ normalizedPatch . length } :${ primary } :${ secondary } ` ;
37+ const primary = fnv1a32 ( patch , FNV_OFFSET_BASIS_32 , FNV_PRIME_32 ) . toString ( 36 ) ;
38+ const secondary = fnv1a32 ( patch , SECONDARY_HASH_SEED , SECONDARY_HASH_MULTIPLIER ) . toString ( 36 ) ;
39+ return `${ scope } :${ patch . length } :${ primary } :${ secondary } ` ;
4540}
4641
4742export type RenderablePatch =
@@ -164,15 +159,10 @@ export function getRenderablePatch(
164159 cacheScope = "diff-panel" ,
165160 options : RenderablePatchOptions = { } ,
166161) : RenderablePatch | null {
167- if ( ! patch ) return null ;
168- const normalizedPatch = patch . trim ( ) ;
169- if ( normalizedPatch . length === 0 ) return null ;
162+ if ( ! patch ?. trim ( ) ) return null ;
170163
171164 try {
172- const parsedPatches = parsePatchFiles (
173- normalizedPatch ,
174- buildPatchCacheKey ( normalizedPatch , cacheScope ) ,
175- ) ;
165+ const parsedPatches = parsePatchFiles ( patch , buildPatchCacheKey ( patch , cacheScope ) ) ;
176166 const sourceFiles = parsedPatches . flatMap ( ( parsedPatch ) => parsedPatch . files ) ;
177167 const files = sourceFiles . map ( ( file ) => {
178168 const filtered = options . ignoreWhitespace ? hideWhitespaceChanges ( file ) : file ;
@@ -184,13 +174,13 @@ export function getRenderablePatch(
184174
185175 return {
186176 kind : "raw" ,
187- text : normalizedPatch ,
177+ text : patch ,
188178 reason : "Unsupported diff format. Showing raw patch." ,
189179 } ;
190180 } catch {
191181 return {
192182 kind : "raw" ,
193- text : normalizedPatch ,
183+ text : patch ,
194184 reason : "Failed to parse patch. Showing raw patch." ,
195185 } ;
196186 }
0 commit comments