Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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