diff options
author | Validark <Validarkness@gmail.com> | 2022-07-08 06:13:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 06:13:52 -0500 |
commit | fa22d95a5c26ed6b917dda43f61781c0b709f282 (patch) | |
tree | 3df3505d516e2d05c9db4b49d721491f663fc4bf | |
parent | ed183860289664af0f3727307653c9bf2bccdc80 (diff) | |
download | lpeglabel-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.lua | 3 |
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 | |||
285 | local function calcline (s, i) | 285 | local 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 | ||
290 | end | 289 | end |
291 | 290 | ||
292 | 291 | ||