Skip to content

Commit

Permalink
Update LocationConverter.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 18, 2024
1 parent 6d92dd9 commit 27a7d29
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Verify.SourceGenerators/Converters/LocationConverter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class LocationConverter :
WriteOnlyJsonConverter<Location>
{
const int contextLines = 1;

public override void Write(VerifyJsonWriter writer, Location value)
{
var lineSpan = value.GetMappedLineSpan();
Expand All @@ -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);

This comment has been minimized.

Copy link
@RReverser

RReverser Sep 18, 2024

Contributor

FWIW I kept it as a constant because I kept going forth and back on how much is useful - sometimes +-2 lines, sometimes +-1 like here - so decided to keep it extracted for easier changes in the future.

This comment has been minimized.

Copy link
@SimonCropp

SimonCropp Sep 18, 2024

Author Member

good point. i will revert this

var endLine = Math.Min(lineSpan.EndLinePosition.Line + 1, lines.Count - 1);
for (var index = startLine; index <= endLine; index++)
{
var line = lines[index];
Expand Down

0 comments on commit 27a7d29

Please sign in to comment.