Skip to content

Commit c051032

Browse files
committed
fix: invert or a | !a
1 parent 8ec164b commit c051032

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/fzf.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,11 @@ int32_t fzf_get_score(const char *text, fzf_pattern_t *pattern,
11771177
}
11781178

11791179
if (term->inv) {
1180-
current_score = 0;
1180+
if (term_set->size > 1) {
1181+
current_score = 1;
1182+
} else {
1183+
current_score = 0;
1184+
}
11811185
matched = true;
11821186
}
11831187
}

test/fzf_lib_spec.lua

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ describe("fzf", function()
5454
fzf.free_pattern(p)
5555
end)
5656

57+
it("can get the score for issue 52", function()
58+
local p = fzf.parse_pattern("a | !a", 0)
59+
eq(1, fzf.get_score("test/minrc.vim", p, slab))
60+
fzf.free_pattern(p)
61+
end)
62+
5763
it("can get the pos for simple pattern", function()
5864
local p = fzf.parse_pattern("fzf", 0)
5965
eq({ 7, 6, 5 }, fzf.get_pos("src/fzf", p, slab))

test/test.c

+6
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,12 @@ TEST(ScoreIntegration, invertAnd) {
643643
score_wrapper("!fzf !test", input, expected);
644644
}
645645

646+
TEST(ScoreIntegration, invertOr) {
647+
char *input[] = {"Makefile", "test/minrc", NULL};
648+
int expected[] = {16, 1};
649+
score_wrapper("a | !a", input, expected);
650+
}
651+
646652
TEST(ScoreIntegration, withEscapedSpace) {
647653
char *input[] = {"file ", "file lua", "lua", NULL};
648654
int expected[] = {0, 200, 0};

0 commit comments

Comments
 (0)