add tweak extra_word_break_chars to completion mode

This commit is contained in:
un-pogaz 2026-03-26 09:58:51 +01:00
parent ce7a4bb490
commit 56544fd826
2 changed files with 12 additions and 1 deletions

View File

@ -504,7 +504,13 @@ tab_accepts_uncompleted_text = False
# There is also a 'word-prefix' mode that matches only at the start of words,
# so typing 'asi' will match Asimov and "Isaac Asimov" but not Quasimodo.
# Similarly, typing 'cat' will match cathedral and "tabby cat" but not education.
#
# If completion_mode is 'word-prefix', you can specify additionals word break chars
# with the extra_word_break_chars list.
# For example, for extra_word_break_chars = ['-'], typing 'fic' will match
# both "Science Fiction" and "Science-Fiction", instead of only the first one.
completion_mode = 'prefix'
extra_word_break_chars = []
#: Sort the list of libraries alphabetically
# The list of libraries in the Copy to library and Quick switch menus are

View File

@ -63,6 +63,10 @@ class CompleteModel(QAbstractListModel): # {{{
completion_mode = get_completion_mode()
self.use_startswith_search = completion_mode == 'prefix'
self.use_word_prefix_search = completion_mode == 'word-prefix'
ewbc = tweaks['extra_word_break_chars'] or ''
if not isinstance(ewbc, str):
ewbc = ''.join(ewbc)
self.extra_word_break_chars = ''.join(set(ewbc))
def set_items(self, items):
if self.strip_completion_entries:
@ -87,7 +91,8 @@ class CompleteModel(QAbstractListModel): # {{{
return
subset = prefix.startswith(old_prefix)
universe = self.current_items if subset else self.all_items
word_iterator = get_word_break_iterator_with_extra_chars(extra_break_chars=hierarchy_separator)
extra_break_chars = hierarchy_separator + self.extra_word_break_chars
word_iterator = get_word_break_iterator_with_extra_chars(extra_break_chars=extra_break_chars)
collator = primary_collator()
word_prefix_match = partial(word_prefix_matcher, collator, word_iterator)
if self.use_word_prefix_search: