Add regex.find_offsets, regex.find, improve regex.match (#1232)

`regex.match` now behaves like `string.match`.
This required changes in the `tokenizer` and in the `detectindent` 
plugin.
This commit is contained in:
Guldoman
2022-12-11 22:25:42 -04:00
committed by GitHub
parent e13f265fac
commit 9d48441685
4 changed files with 88 additions and 28 deletions
+4 -4
View File
@@ -190,11 +190,11 @@ local function get_non_empty_lines(syntax, lines)
end
else
if comment[3] then
local start, ending = regex.match(
local start, ending = regex.find_offsets(
comment[2], line, 1, regex.ANCHORED
)
if start then
if not regex.match(
if not regex.find_offsets(
comment[3], line, ending+1, regex.ANCHORED
)
then
@@ -204,7 +204,7 @@ local function get_non_empty_lines(syntax, lines)
end
break
end
elseif regex.match(comment[2], line, 1, regex.ANCHORED) then
elseif regex.find_offsets(comment[2], line, 1, regex.ANCHORED) then
is_comment = true
break
end
@@ -214,7 +214,7 @@ local function get_non_empty_lines(syntax, lines)
is_comment = true
inside_comment = false
end_pattern = nil
elseif end_regex and regex.match(end_regex, line) then
elseif end_regex and regex.find_offsets(end_regex, line) then
is_comment = true
inside_comment = false
end_regex = nil