Skip to content

Commit

Permalink
feat(state): allow passing a callable object as matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 24, 2023
1 parent b9c2137 commit f49fa9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/flash/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local Pattern = require("flash.search.pattern")
---@field wins window[]
---@field cache Flash.Cache
---@field pos Pos
---@field view any
---@field results Flash.Match[]
---@field target? Flash.Match
---@field pattern Flash.Pattern
Expand Down Expand Up @@ -81,7 +82,12 @@ function M.new(opts)
self.results = {}
self.matchers = {}
self.wins = {}
self.matcher = self.opts.matcher and Matcher.from(self.opts.matcher) or Search.new
self.matcher = self.opts.matcher
if type(self.matcher) == "function" then
self.matcher = Matcher.from(self.opts.matcher)
elseif self.matcher == nil then
self.matcher = Search.new
end
self.pattern = Pattern.new(self.opts.pattern, self.opts.search.mode, self.opts.search.trigger)
self.visible = true
self.cache = Cache.new(self)
Expand Down

0 comments on commit f49fa9c

Please sign in to comment.