TailBlazer icon indicating copy to clipboard operation
TailBlazer copied to clipboard

Negative Index when reading lines using scroll request with position

Open mgnslndh opened this issue 8 years ago • 0 comments

Reading lines using a ScrollRequest with a position instead of a firstIndex result in a negative Index for the first line.

[Fact]
public void IndexShouldNotBeNegative()
{
    var firstLine = "This is the first line";

    ILineProvider result = null;

    var pulse = new Subject<Unit>();

    using (var file = new TestFile())
    using (file.Info
        .WatchFile(pulse)
        .Index()                
        .Subscribe(x => result = x))
    {

        file.Append(firstLine);

        pulse.Once();

        var lines = result.ReadLines(new ScrollRequest(10, (long)4)).ToArray();
        lines.Single().Index.Should().BeGreaterOrEqualTo(0);
    }
}

mgnslndh avatar Apr 26 '16 12:04 mgnslndh