From 6a0354a597fd498d99006c8321c6aa232a838969 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 31 Jan 2017 22:30:23 +0000 Subject: [PATCH] Tweak ranked match ordering --- src/ranked_match.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ranked_match.cc b/src/ranked_match.cc index 34d38351..1de8713e 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -177,7 +177,8 @@ bool RankedMatch::operator<(const RankedMatch& other) const if (diff != Flags::None) return (int)(m_flags & diff) > (int)(other.m_flags & diff); - if (m_word_boundary_match_count != other.m_word_boundary_match_count) + if (not (m_flags & Flags::Prefix) and + m_word_boundary_match_count != other.m_word_boundary_match_count) return m_word_boundary_match_count > other.m_word_boundary_match_count; if (m_max_index != other.m_max_index) @@ -223,6 +224,7 @@ UnitTest test_ranked_match{[] { 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"}); + kak_assert(RankedMatch{"class", "cla"} < RankedMatch{"class::attr", "cla"}); }}; UnitTest test_used_letters{[]()