From e92d2c8812f4b7241437fe60b0e0a30435915297 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 19 Sep 2024 07:16:54 +1000 Subject: [PATCH] Revert "Update LocationConverter.cs" This reverts commit 27a7d2962a4300a7d888488c49f45eeebec9940d. --- src/Verify.SourceGenerators/Converters/LocationConverter.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Verify.SourceGenerators/Converters/LocationConverter.cs b/src/Verify.SourceGenerators/Converters/LocationConverter.cs index e77d10a..7124e66 100644 --- a/src/Verify.SourceGenerators/Converters/LocationConverter.cs +++ b/src/Verify.SourceGenerators/Converters/LocationConverter.cs @@ -1,6 +1,8 @@ class LocationConverter : WriteOnlyJsonConverter { + const int contextLines = 1; + public override void Write(VerifyJsonWriter writer, Location value) { var lineSpan = value.GetMappedLineSpan(); @@ -21,8 +23,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 - 1, 0); - var endLine = Math.Min(lineSpan.EndLinePosition.Line + 1, lines.Count - 1); + var startLine = Math.Max(lineSpan.StartLinePosition.Line - contextLines, 0); + var endLine = Math.Min(lineSpan.EndLinePosition.Line + contextLines, lines.Count - 1); for (var index = startLine; index <= endLine; index++) { var line = lines[index];