diff options
| author | Fuwn <[email protected]> | 2024-02-11 00:05:50 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-11 00:05:50 -0800 |
| commit | 09c484211a91d544f93e5ce4cb8371ea0a5728e0 (patch) | |
| tree | c04f7fcbcbfd014781a87c1e3ff774aefec4598d /src/lib/Error | |
| parent | feat(error): add hololive suggestion (diff) | |
| download | due.moe-09c484211a91d544f93e5ce4cb8371ea0a5728e0.tar.xz due.moe-09c484211a91d544f93e5ce4cb8371ea0a5728e0.zip | |
feat(error): return partial matches first
Diffstat (limited to 'src/lib/Error')
| -rw-r--r-- | src/lib/Error/path.ts | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/Error/path.ts b/src/lib/Error/path.ts index ea11fa69..75c035d7 100644 --- a/src/lib/Error/path.ts +++ b/src/lib/Error/path.ts @@ -9,5 +9,8 @@ export const closest = (path: string, suggestions: string[]) => { suggestionsWithDistance.sort((a, b) => a.distance - b.distance); + for (const suggestion of suggestionsWithDistance) + if (suggestion.distance < suggestion.suggestion.length / 2) return suggestion.suggestion; + return suggestionsWithDistance[0].suggestion; }; |