1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:45:08 +00:00

Help: Perform a fuzzy match on the page title when searching

This allows for slight misspellings to still return a result.
This commit is contained in:
Tim Ledbetter 2023-04-26 17:22:47 +01:00 committed by Andrew Kaster
parent d1b5eec154
commit a042c4e93d

View file

@ -5,6 +5,7 @@
*/
#include "ManualModel.h"
#include <AK/FuzzyMatch.h>
#include <AK/Try.h>
#include <AK/Utf8View.h>
#include <LibManual/Node.h>
@ -213,7 +214,8 @@ TriState ManualModel::data_matches(const GUI::ModelIndex& index, const GUI::Vari
if (!name.has_value())
return TriState::False;
if (name.value().bytes_as_string_view().contains(term.as_string(), CaseSensitivity::CaseInsensitive))
auto match_result = fuzzy_match(term.as_string(), name.value());
if (match_result.score > 0)
return TriState::True;
auto path = page_path(index);