Tweak RankedMatch behaviour and fix bug in its comparison function
casting TestableFlag<T> to UnderlyingType<T> was going through bool conversion... Not sure how things worked earlier.
This commit is contained in:
parent
b3ba769220
commit
6d79ade019
|
@ -37,6 +37,7 @@ struct TestableFlags
|
||||||
Flags value;
|
Flags value;
|
||||||
constexpr operator bool() const { return (UnderlyingType<Flags>)value; }
|
constexpr operator bool() const { return (UnderlyingType<Flags>)value; }
|
||||||
constexpr operator Flags() const { return value; }
|
constexpr operator Flags() const { return value; }
|
||||||
|
constexpr operator UnderlyingType<Flags>() const { return (UnderlyingType<Flags>)value; }
|
||||||
|
|
||||||
bool operator==(const TestableFlags<Flags>& other) const { return value == other.value; }
|
bool operator==(const TestableFlags<Flags>& other) const { return value == other.value; }
|
||||||
bool operator!=(const TestableFlags<Flags>& other) const { return value != other.value; }
|
bool operator!=(const TestableFlags<Flags>& other) const { return value != other.value; }
|
||||||
|
|
|
@ -216,6 +216,8 @@ UnitTest test_ranked_match{[] {
|
||||||
kak_assert(not (RankedMatch{"source", "so"} < RankedMatch{"source", "so"}));
|
kak_assert(not (RankedMatch{"source", "so"} < RankedMatch{"source", "so"}));
|
||||||
kak_assert(RankedMatch{"single/word", "wo"} < RankedMatch{"multiw/ord", "wo"});
|
kak_assert(RankedMatch{"single/word", "wo"} < RankedMatch{"multiw/ord", "wo"});
|
||||||
kak_assert(RankedMatch{"foo/bar/foobar", "foobar"} < RankedMatch{"foo/bar/baz", "foobar"});
|
kak_assert(RankedMatch{"foo/bar/foobar", "foobar"} < RankedMatch{"foo/bar/baz", "foobar"});
|
||||||
|
kak_assert(RankedMatch{"delete-buffer", "db"} < RankedMatch{"debug", "db"});
|
||||||
|
kak_assert(RankedMatch{"create_task", "ct"} < RankedMatch{"constructor", "ct"});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
UnitTest test_used_letters{[]()
|
UnitTest test_used_letters{[]()
|
||||||
|
|
|
@ -37,11 +37,11 @@ private:
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
// Order is important, the highest bit has precedence for comparison
|
// Order is important, the highest bit has precedence for comparison
|
||||||
OnlyWordBoundary = 1 << 0,
|
FirstCharMatch = 1 << 0,
|
||||||
FirstCharMatch = 1 << 1,
|
SingleWord = 1 << 1,
|
||||||
Prefix = 1 << 2,
|
Contiguous = 1 << 2,
|
||||||
SingleWord = 1 << 3,
|
OnlyWordBoundary = 1 << 3,
|
||||||
Contiguous = 1 << 4,
|
Prefix = 1 << 4,
|
||||||
FullMatch = 1 << 5,
|
FullMatch = 1 << 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user