diff --git a/data/core/doc/search.lua b/data/core/doc/search.lua index 3fc19c70..7fc85c41 100644 --- a/data/core/doc/search.lua +++ b/data/core/doc/search.lua @@ -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 diff --git a/data/core/regex.lua b/data/core/regex.lua index 3b343238..690e04b0 100644 --- a/data/core/regex.lua +++ b/data/core/regex.lua @@ -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