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

Change entry search to be fuzzy. #218

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Changelog

- Focus the task entry on Ctrl+L (GH: #213).

- Change entry search to be fuzzy. It is now only required to enter characters
of the entry in the correct order to find an entry.


0.11.3 (2019-04-23)
~~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 13 additions & 0 deletions src/gtimelog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,22 @@ def set_up_completion(self):
self.completion_choices_as_set = set()
completion.set_model(self.completion_choices)
completion.set_text_column(0)
completion.set_match_func(
self.completion_match_func, self.completion_choices)
if self.gtk_completion_enabled:
self.set_completion(completion)

def completion_match_func(self, completion, search_text, tree_iter, data):
entry = data.get_value(tree_iter, 0).lower()
pos = 0
for char in search_text:
new_pos = entry.find(char, pos)
if new_pos == -1:
return False
else:
pos = new_pos
return True

def gtk_completion_enabled_changed(self, *args):
if self.gtk_completion_enabled:
self.set_completion(self.gtk_completion)
Expand Down