Fixed offsets, and passed through an additional parameter.

This commit is contained in:
Adam Harrison 2021-05-06 19:22:36 -04:00
parent 88c5424e0b
commit a100a7b6a9
2 changed files with 4 additions and 4 deletions

View File

@ -33,9 +33,9 @@ function search.find(doc, line, col, text, opt)
for line = line, #doc.lines do
local line_text = doc.lines[line]
if opt.regex then
local s, e = re:match(line_text, col, true)
local s, e = re:cmatch(line_text, col, true)
if s then
return line, s, line, e + 1
return line, s, line, e
end
col = 1
else

View File

@ -3,10 +3,10 @@
-- pattern:gsub(string).
regex.__index = function(table, key) return regex[key]; end
regex.match = function(pattern_string, string)
regex.match = function(pattern_string, string, offset)
local pattern = type(pattern_string) == "table" and
pattern_string or regex.compile(pattern_string)
return regex.cmatch(pattern, string)
return regex.cmatch(pattern, string, offset)
end
-- Will iterate back through any UTF-8 bytes so that we don't replace bits