Skip to content

Commit

Permalink
fix: invert or a | !a
Browse files Browse the repository at this point in the history
  • Loading branch information
Conni2461 committed Feb 19, 2022
1 parent 8ec164b commit c051032
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fzf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,11 @@ int32_t fzf_get_score(const char *text, fzf_pattern_t *pattern,
}

if (term->inv) {
current_score = 0;
if (term_set->size > 1) {
current_score = 1;
} else {
current_score = 0;
}
matched = true;
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/fzf_lib_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ describe("fzf", function()
fzf.free_pattern(p)
end)

it("can get the score for issue 52", function()
local p = fzf.parse_pattern("a | !a", 0)
eq(1, fzf.get_score("test/minrc.vim", p, slab))
fzf.free_pattern(p)
end)

it("can get the pos for simple pattern", function()
local p = fzf.parse_pattern("fzf", 0)
eq({ 7, 6, 5 }, fzf.get_pos("src/fzf", p, slab))
Expand Down
6 changes: 6 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,12 @@ TEST(ScoreIntegration, invertAnd) {
score_wrapper("!fzf !test", input, expected);
}

TEST(ScoreIntegration, invertOr) {
char *input[] = {"Makefile", "test/minrc", NULL};
int expected[] = {16, 1};
score_wrapper("a | !a", input, expected);
}

TEST(ScoreIntegration, withEscapedSpace) {
char *input[] = {"file ", "file lua", "lua", NULL};
int expected[] = {0, 200, 0};
Expand Down

0 comments on commit c051032

Please sign in to comment.