@@ -194,11 +194,7 @@ public String wfpForContents(@NonNull String filename, Boolean binFile, byte[] c
194194 if (lastLine != line ) {
195195 int obLength = outputBuilder .length ();
196196 if (obLength > 0 ) {
197- if (snippetLimit > 0 && obLength > snippetLimit ) {
198- log .debug ("Skipping snippet line as it's too big ({}): {}" , filename , outputBuilder );
199- } else {
200- wfpBuilder .append (outputBuilder ).append ("\n " );
201- }
197+ wfpBuilder .append (outputBuilder ).append ("\n " );
202198 }
203199 outputBuilder .delete (0 , obLength );
204200 outputBuilder .append (String .format ("%d=%s" , line , minHashHex ));
@@ -216,11 +212,7 @@ public String wfpForContents(@NonNull String filename, Boolean binFile, byte[] c
216212 }
217213 int obLength = outputBuilder .length ();
218214 if (obLength > 0 ) {
219- if (snippetLimit > 0 && obLength > snippetLimit ) {
220- log .debug ("Skipping snippet line as it's too big ({}) {} - {}: {}" , filename , snippetLimit , obLength , outputBuilder );
221- } else {
222- wfpBuilder .append (outputBuilder ).append ("\n " );
223- }
215+ wfpBuilder .append (outputBuilder ).append ("\n " );
224216 }
225217 return wfpBuilder .toString ();
226218 }
@@ -288,6 +280,21 @@ private Boolean skipSnippets(@NonNull String filename, char[] contents) {
288280 }
289281 }
290282 }
283+ // Check if first line is too long (matches Python implementation)
284+ int firstLineEnd = 0 ;
285+ for (int i = 0 ; i < contents .length ; i ++) {
286+ if (contents [i ] == '\n' ) {
287+ firstLineEnd = i ;
288+ break ;
289+ }
290+ }
291+ if (firstLineEnd == 0 ) {
292+ firstLineEnd = contents .length ; // No newline found, use entire content length
293+ }
294+ if (snippetLimit > 0 && firstLineEnd > snippetLimit ) {
295+ log .trace ("Skipping snippets due to first line being too long: {} - {} chars" , filename , firstLineEnd );
296+ return true ;
297+ }
291298 return false ;
292299 }
293300
0 commit comments