Skip Menu |

This queue is for tickets about the Text-LineNumber CPAN distribution.

Report information
The Basics
Id: 131947
Status: new
Priority: 0/
Queue: Text-LineNumber

People
Owner: Nobody in particular
Requestors: CXW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.02
Fixed in: (no value)



Subject: Off-by-one line number in strings without \n or with leading \n
Thank you for this module! I would like to use in one of my dists. I noticed that the line number is off by one if the text does not include a \n, or if the text starts with a \n. I have tests at https://github.com/cxw42/Text-LineNumber/blob/master/t/15-other.t : lines 12, 15, and 41 fail. For example, with Text::LineNumber v0.02 installed: perl -MText::LineNumber -E 'my $tln = Text::LineNumber->new(q(12345)); say join q(:), $tln->off2lnr(1)' prints `0:2` but should print `1:2`, and perl -MText::LineNumber -E 'my $tln = Text::LineNumber->new(qq(\n12345)); say join q(:), $tln->off2lnr(1)' prints `1:2` but should print `2:1`. I would be happy to work on a fix for these if you would be open to receiving one. I started my GitHub repo (https://github.com/cxw42/Text-LineNumber) with v0.02 from CPAN and can build from there. Thank you for considering this report! Sincerely, Chris White