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 for line = line, #doc.lines do
local line_text = doc.lines[line] local line_text = doc.lines[line]
if opt.regex then 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 if s then
return line, s, line, e + 1 return line, s, line, e
end end
col = 1 col = 1
else else

View File

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