From 62380e027e221e37c8a2c2491af896ed13eb2c32 Mon Sep 17 00:00:00 2001 From: SantoJambit <53570854+SantoJambit@users.noreply.github.com> Date: Sun, 11 Apr 2021 22:14:14 +0200 Subject: [PATCH] Case insensitive search (#41) * case insensitive search * prettier --- extension.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/extension.ts b/extension.ts index 9dafc04..97dd4ac 100644 --- a/extension.ts +++ b/extension.ts @@ -162,9 +162,20 @@ const lookupRecentItems = ( const recentItemMatchesTerms = ( item: RecentItem, terms: ReadonlyArray | null -): boolean => - terms !== null && - terms.every((t) => item.name.includes(t) || item.readablePath.includes(t)); +): boolean => { + if (!terms) { + return false; + } else { + const lowerName = item.name.toLowerCase(); + const lowerReadablePath = item.readablePath.toLowerCase(); + return terms.every((term) => { + const lowerTerm = term.toLowerCase(); + return ( + lowerName.includes(lowerTerm) || lowerReadablePath.includes(lowerTerm) + ); + }); + } +}; /** * Find all items which match all of the given terms and have a kind contained in `kinds`.