From 27a7d2962a4300a7d888488c49f45eeebec9940d Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 18 Sep 2024 21:30:26 +1000 Subject: [PATCH] Update LocationConverter.cs --- src/Verify.SourceGenerators/Converters/LocationConverter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Verify.SourceGenerators/Converters/LocationConverter.cs b/src/Verify.SourceGenerators/Converters/LocationConverter.cs index 7124e66..e77d10a 100644 --- a/src/Verify.SourceGenerators/Converters/LocationConverter.cs +++ b/src/Verify.SourceGenerators/Converters/LocationConverter.cs @@ -1,8 +1,6 @@ class LocationConverter : WriteOnlyJsonConverter { - const int contextLines = 1; - public override void Write(VerifyJsonWriter writer, Location value) { var lineSpan = value.GetMappedLineSpan(); @@ -23,8 +21,8 @@ static void WriteSourceTree(VerifyJsonWriter writer, Location value, FileLinePos var comment = new StringBuilder(); comment.AppendLine(); var lines = source.GetText().Lines; - var startLine = Math.Max(lineSpan.StartLinePosition.Line - contextLines, 0); - var endLine = Math.Min(lineSpan.EndLinePosition.Line + contextLines, lines.Count - 1); + var startLine = Math.Max(lineSpan.StartLinePosition.Line - 1, 0); + var endLine = Math.Min(lineSpan.EndLinePosition.Line + 1, lines.Count - 1); for (var index = startLine; index <= endLine; index++) { var line = lines[index];