Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ranked match: prefer when each path component matches within a path component #5033

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

krobelus
Copy link
Contributor

@@ -52,6 +53,7 @@ private:
StringView m_candidate{};
bool m_matches = false;
Flags m_flags = Flags::None;
Vector<RankedMatch, MemoryDomain::RankedMatch> m_path_component_matches;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these semantics are okay we could get rid of this allocation by computing the path component matches lazily in RankedMatch::operator<. I think this could work fine because we use a heap to get the top 100 or so completions, so we never need to sort everything; the number of calls to RankedMatch::operator< is linear.
I'd need to check.

kak_assert(m_path_component_matches.size() == other.m_path_component_matches.size());
for (auto [lhs, rhs] : zip(m_path_component_matches, other.m_path_component_matches))
if (*lhs < *rhs)
return true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably if we use the same recursive-matching for the basename (even if the query contains no slash) then we can make @raiguard's test work:

kak_assert(preferred("luaremote", "src/script/LuaRemote.cpp", "tests/TestLuaRemote.cpp"));

because luaremote is a prefix (or is it?) of the basename so the RankedMatch will win

@krobelus krobelus force-pushed the prefer-component-wise-matches branch from f0aadc2 to e445517 Compare December 2, 2023 07:31
krobelus added a commit to krobelus/kakoune that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant