Skip to content

Commit

Permalink
Search terms starting with ~ now enable fuzzy searching
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruor committed Oct 19, 2023
1 parent fd97049 commit 978f4b0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ui/widgets/lists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local widgetUtils = require("ui.widgets.utils")
local textSearching = require("utils.text_search")
local configs = require("configs")
local keyboard = require("utils.keyboard")
local utils = require("utils")

local listWidgets = {}

Expand Down Expand Up @@ -36,6 +37,12 @@ local function defaultFilterItems(items, search, options)
local fuzzy = configs.ui.searching.searchFuzzy
local caseSensitive = getCaseSensitive(search)

-- Enable fuzzy search if the term starts with ~
if utils.startsWith(search, "~") then
fuzzy = true
search = string.sub(search, 2)
end

if searchPreprocessor then
search = searchPreprocessor(search, caseSensitive, fuzzy)
end
Expand Down Expand Up @@ -746,4 +753,4 @@ function listWidgets.getMagicList(callback, items, options)
return getListCommon(true, callback, items, options)
end

return listWidgets
return listWidgets

0 comments on commit 978f4b0

Please sign in to comment.