Merge pull request #629 from Guldoman/avoid_patterns_search

Use plain search by default in `search.find`
This commit is contained in:
Adam 2021-10-31 13:55:30 -04:00 committed by GitHub
commit 920982cbe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -43,6 +43,7 @@ end
function search.find(doc, line, col, text, opt)
doc, line, col, text, opt = init_args(doc, line, col, text, opt)
local plain = not opt.pattern
local pattern = text
local search_func = string.find
if opt.regex then
@ -60,9 +61,9 @@ function search.find(doc, line, col, text, opt)
end
local s, e
if opt.reverse then
s, e = rfind(search_func, line_text, pattern, col - 1)
s, e = rfind(search_func, line_text, pattern, col - 1, plain)
else
s, e = search_func(line_text, pattern, col)
s, e = search_func(line_text, pattern, col, plain)
end
if s then
return line, s, line, e + 1