diff options
-rw-r--r-- | relabel.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/relabel.lua b/relabel.lua index 8b12811..6fdbb7c 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -352,14 +352,15 @@ local pattern = S * m.Cg(m.Cc(false), "G") * expect(exp, "NoPatt") / mm.P | |||
352 | 352 | ||
353 | local function lineno (s, i) | 353 | local function lineno (s, i) |
354 | if i == 1 then return 1, 1 end | 354 | if i == 1 then return 1, 1 end |
355 | local adjust = 0 | 355 | local adjustment = 0 |
356 | -- report the current line if at end of line, not the next | ||
356 | if s:sub(i,i) == '\n' then | 357 | if s:sub(i,i) == '\n' then |
357 | i = i-1 | 358 | i = i-1 |
358 | adjust = 1 | 359 | adjustment = 1 |
359 | end | 360 | end |
360 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") | 361 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") |
361 | local r = #rest | 362 | local r = #rest |
362 | return 1 + num, (r ~= 0 and r or 1) + adjust | 363 | return 1 + num, (r ~= 0 and r or 1) + adjustment |
363 | end | 364 | end |
364 | 365 | ||
365 | local function splitlines(str) | 366 | local function splitlines(str) |