fix(picker.matcher): regex offset by one. Fixes #878

This commit is contained in:
Folke Lemaitre 2025-02-02 23:41:18 +01:00
parent 392245e627
commit 9a82f0a564
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 2 additions and 1 deletions

View file

@ -570,7 +570,7 @@ function M:render()
if self.matcher.pattern ~= pattern then
self.matcher:init(pattern)
end
local search = vim.trim(self.picker.input.filter.search)
local search = Snacks.picker.util.parse(vim.trim(self.picker.input.filter.search))
if self.matcher_regex.pattern ~= search then
self.matcher_regex:init(search)
end

View file

@ -438,6 +438,7 @@ function M:regex(str, pattern)
end
local from, to = re:match_str(str)
if from and to then
from = from + 1
return self.score:get(str, from, to), from, to, str
end
end