aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValidark <Validarkness@gmail.com>2022-07-08 06:13:52 -0500
committerGitHub <noreply@github.com>2022-07-08 06:13:52 -0500
commitfa22d95a5c26ed6b917dda43f61781c0b709f282 (patch)
tree3df3505d516e2d05c9db4b49d721491f663fc4bf
parented183860289664af0f3727307653c9bf2bccdc80 (diff)
downloadlpeglabel-fa22d95a5c26ed6b917dda43f61781c0b709f282.tar.gz
lpeglabel-fa22d95a5c26ed6b917dda43f61781c0b709f282.tar.bz2
lpeglabel-fa22d95a5c26ed6b917dda43f61781c0b709f282.zip
Fix calcline returning the wrong column
Previously, column numbers would effectively start at 0, except the first character would register as 1 so the column numbers would go `11234567`.
-rw-r--r--relabel.lua3
1 files changed, 1 insertions, 2 deletions
diff --git a/relabel.lua b/relabel.lua
index df5c8c8..f4f4546 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -285,8 +285,7 @@ end
285local function calcline (s, i) 285local function calcline (s, i)
286 if i == 1 then return 1, 1 end 286 if i == 1 then return 1, 1 end
287 local rest, line = s:sub(1,i):gsub("[^\n]*\n", "") 287 local rest, line = s:sub(1,i):gsub("[^\n]*\n", "")
288 local col = #rest 288 return 1 + line, #rest + 1
289 return 1 + line, col ~= 0 and col or 1
290end 289end
291 290
292 291