Skip to content

Commit c152c18

Browse files
committed
fix: accept negative match in fzf matcher
1 parent f4f0f0f commit c152c18

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builtin/matcher/fzf.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ export function fzf(options: FzfOptions = {}): Matcher {
6666
.map((v) => {
6767
const column = Math.max(0, v.start + 1);
6868
const length = Math.max(0, v.end - v.start);
69-
if (length === 0) return undefined;
69+
70+
// NOTE:
71+
// The length become 0 when user use negative match like (!a).
72+
const decorations = (length === 0) ? [] : [{ column, length }];
7073

7174
return {
7275
...v.item,
7376
decorations: [
7477
...(v.item.decorations ?? []),
75-
{ column, length },
78+
...decorations,
7679
],
7780
};
7881
})
@@ -88,6 +91,6 @@ export function fzf(options: FzfOptions = {}): Matcher {
8891
}
8992

9093
// deno-lint-ignore no-explicit-any
91-
const byTrimmedLengthAsc: Tiebreaker<IdItem<any>> = (a, b, selector) => {
94+
const byTrimmedLengthAsc: Tiebreaker<any> = (a, b, selector) => {
9295
return selector(a.item).trim().length - selector(b.item).trim().length;
9396
};

0 commit comments

Comments
 (0)