From 0137a45e19e425776dd6e52121b6900c95bf2d42 Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Sun, 25 Dec 2022 16:28:00 +0000 Subject: [PATCH] feat: add alternative suggestions for simple_lookup_map plugins --- crates/tailwind-parse/src/eval/plugin.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/tailwind-parse/src/eval/plugin.rs b/crates/tailwind-parse/src/eval/plugin.rs index f84a7be..9d65898 100644 --- a/crates/tailwind-parse/src/eval/plugin.rs +++ b/crates/tailwind-parse/src/eval/plugin.rs @@ -201,7 +201,15 @@ fn simple_lookup_map<'a, V>( hashmap .get(search) .map(|val| to_lit(&[(output, &f(val))])) - .ok_or_else(Vec::new) + .ok_or_else(|| { + let sort = eddie::Levenshtein::new(); + hashmap + .keys() + .sorted_by_key(|val| sort.distance(search, val)) + .copied() + .take(5) + .collect() + }) } lookup_plugin_opt!(transition, transition_property, "transitionProperty");