diff --git a/Grepl.Tests/Commands/BasicCommands.cs b/Grepl.Tests/Commands/BasicCommands.cs index 775eb23..76aca70 100644 --- a/Grepl.Tests/Commands/BasicCommands.cs +++ b/Grepl.Tests/Commands/BasicCommands.cs @@ -627,5 +627,24 @@ public void Should_30_show_only_file_name_replace_save() } + [TestMethod] + public void Should_10_exclude_zero_length_match() + { + File.WriteAllText("test.txt", "abc\n"); + + var r = GreplEntry(".*", "-r"); + Assert.AreEqual(0, r.Code); + + var raw = r.Output; + var exp = @" +test.txt +abc +"; + + CompareDetails(exp, raw); + + Assert.AreEqual(exp, raw); + + } } } diff --git a/Grepl/Executor.cs b/Grepl/Executor.cs index d34f733..5e2d402 100644 --- a/Grepl/Executor.cs +++ b/Grepl/Executor.cs @@ -269,6 +269,10 @@ void Process(string file, bool printFileName, Dictionary= length (zero length match at the end of a string) + } // find the start of the line var lineStart = body.LastIndexOf('\n', match.Index); lineStart++;