Skip to content

Commit 6b6bbb0

Browse files
committed
Update CrossChunkMatcher.cs
1 parent 19e4e72 commit 6b6bbb0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/Verify/Serialization/Scrubbers/CrossChunkMatcher.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ public static void ReplaceAll<TContext>(
3838
var windowSlice = buffer[..bufferLength];
3939
var result = matcher(windowSlice, absolutePosition, context);
4040

41-
if (result.IsMatch)
41+
if (!result.IsMatch)
4242
{
43-
matches.Add(new Match(absolutePosition, result.MatchLength, result.Replacement));
44-
45-
// Skip past the match
46-
var skipAmount = result.MatchLength - 1;
47-
if (skipAmount > 0)
48-
{
49-
var remaining = chunk.Length - chunkIndex - 1;
50-
var toSkip = Math.Min(skipAmount, remaining);
51-
chunkIndex += toSkip;
52-
}
43+
continue;
5344
}
45+
46+
matches.Add(new(absolutePosition, result.MatchLength, result.Replacement));
47+
48+
// Skip past the match
49+
var skipAmount = result.MatchLength - 1;
50+
if (skipAmount <= 0)
51+
{
52+
continue;
53+
}
54+
55+
var remaining = chunk.Length - chunkIndex - 1;
56+
var toSkip = Math.Min(skipAmount, remaining);
57+
chunkIndex += toSkip;
5458
}
5559

5660
position += chunk.Length;
@@ -140,7 +144,7 @@ public static MatchResult Match(int length, string replacement)
140144
throw new ArgumentException("Match length must be positive", nameof(length));
141145
}
142146

143-
return new MatchResult(true, length, replacement);
147+
return new(true, length, replacement);
144148
}
145149

146150
/// <summary>

0 commit comments

Comments
 (0)