summaryrefslogtreecommitdiff
path: root/script/parser/lines.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/parser/lines.lua')
-rw-r--r--script/parser/lines.lua22
1 files changed, 6 insertions, 16 deletions
diff --git a/script/parser/lines.lua b/script/parser/lines.lua
index 1aba0ae5..964aabf4 100644
--- a/script/parser/lines.lua
+++ b/script/parser/lines.lua
@@ -2,33 +2,23 @@ local sfind = string.find
local ssub = string.sub
---@param text string
-return function (self, text)
+return function (text)
local current = 1
local lines = {}
- local i = 1
+ lines[0] = 1
+ local i = 0
while true do
local pos = sfind(text,'[\r\n]', current)
if not pos then
break
end
- local line = {
- start = current - 1,
- range = pos - 1,
- }
- lines[i] = line
i = i + 1
if ssub(text, pos, pos + 1) == '\r\n' then
- current = pos + 2
- line.finish = pos + 1
+ current = pos + 2
else
- current = pos + 1
- line.finish = pos
+ current = pos + 1
end
+ lines[i] = current
end
- lines[i] = {
- start = current - 1,
- finish = #text,
- range = #text,
- }
return lines
end