From 63efcc06d5bee7f05a1ee9539b2391c80e5d6205 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Apr 2025 17:35:23 +1100 Subject: Tweak ranked match behaviour to consider the number of full words Tracking the number of query words that appear as full words in the candidate seems to fix a few cases where the existing fuzzy matching algorithm was not great. I have been running with this for a while and did not notice any annoyances, the whole RankedMatch code probably deserves more attention but this seems to go in the right direction. --- src/insert_completer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/insert_completer.cc') diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 49bbd4ca..01058012 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -3,7 +3,6 @@ #include "buffer_manager.hh" #include "buffer_utils.hh" #include "debug.hh" -#include "client.hh" #include "command_manager.hh" #include "changes.hh" #include "context.hh" @@ -13,6 +12,7 @@ #include "regex.hh" #include "window.hh" #include "word_db.hh" +#include "word_splitter.hh" #include "option_types.hh" #include "utf8_iterator.hh" #include "user_interface.hh" @@ -87,7 +87,7 @@ InsertCompletion complete_word(const SelectionList& sels, for (int i = 0; i < sels.size(); ++i) { int len = 0; - auto is_short_enough_word = [&] (Codepoint c) { return len++ < WordDB::max_word_len && is_word_pred(c); }; + auto is_short_enough_word = [&] (Codepoint c) { return len++ < WordSplitter::max_word_len && is_word_pred(c); }; Utf8It end{buffer.iterator_at(sels[i].cursor()), buffer}; Utf8It begin = end-1; @@ -103,7 +103,7 @@ InsertCompletion complete_word(const SelectionList& sels, skip_while(end, buffer.end(), is_short_enough_word); - if (len <= WordDB::max_word_len) + if (len <= WordSplitter::max_word_len) { StringView word = buffer.substr(begin.base().coord(), end.base().coord()); ++sel_word_counts[word]; -- cgit v1.2.3