From 990e92a5f320953bab12ba2c0419d382cd68102e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 23 Nov 2023 17:15:20 +1100 Subject: [PATCH] Only set Prefix in RankedMatch if the full query matches --- 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 a0eedda4..d258b680 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -140,7 +140,8 @@ RankedMatch::RankedMatch(StringView candidate, StringView query, TestFunc func) it == candidate.begin() or subsequence_match_smart_case({it, candidate.end()}, query)) { m_flags |= Flags::BaseName; - if (*it == query[0]) + if ((candidate.end() - it) >= query.length() and + std::equal(query.begin(), query.end(), it)) m_flags |= Flags::Prefix; } @@ -277,6 +278,7 @@ UnitTest test_ranked_match{[] { kak_assert(preferred("foo_b", "bar/bar_qux/foo_bar.baz", "foo/test_foo_bar.baz")); kak_assert(preferred("foo_bar", "bar/foo_bar.baz", "foo_bar/qux.baz")); kak_assert(preferred("fb", "foo_bar/", "foo.bar")); + kak_assert(preferred("foo_bar", "test_foo_bar", "foo_test_bar")); }}; UnitTest test_used_letters{[]()