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
+3 -2
View File
@@ -43,6 +43,7 @@ end
function search.find(doc, line, col, text, opt) function search.find(doc, line, col, text, opt)
doc, line, col, text, opt = init_args(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 pattern = text
local search_func = string.find local search_func = string.find
if opt.regex then if opt.regex then
@@ -60,9 +61,9 @@ function search.find(doc, line, col, text, opt)
end end
local s, e local s, e
if opt.reverse then 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 else
s, e = search_func(line_text, pattern, col) s, e = search_func(line_text, pattern, col, plain)
end end
if s then if s then
return line, s, line, e + 1 return line, s, line, e + 1