Skip to content

Commit

Permalink
fix(state): stop searching when max matches reached
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 10, 2023
1 parent 959af4e commit 4245e49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lua/flash/searcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function M._search(win, state)
visible = from[1] >= info.topline and from[1] <= info.botline,
first = vim.deep_equal(from, first),
})
if #matches > Config.search.max_matches then
if #matches >= Config.search.max_matches then
-- vim.notify("Too many matches", vim.log.levels.WARN, { title = "flash.nvim" })
break
end
Expand Down
6 changes: 2 additions & 4 deletions lua/flash/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ function M:search(pattern)
local results = {}
if pattern ~= "" then
for _, win in ipairs(self.wins) do
local r = Searcher.search(win, self)
-- max results reached, so stop searching
if not r then
vim.list_extend(results, Searcher.search(win, self))
if #results >= self.config.search.max_matches then
break
end
vim.list_extend(results, r)
end
end
self:set(results)
Expand Down

0 comments on commit 4245e49

Please sign in to comment.