-
Notifications
You must be signed in to change notification settings - Fork 114
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
New search #558
base: master
Are you sure you want to change the base?
New search #558
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :-) I only have a few comments. Maybe the bug you're seeing will be gone after taking care of these.
38263d8
to
d79034e
Compare
@jendrikseipp After the latest changes, indeed the bug went away. (I was actually still checking the old I've found another bug now which causes an exception if only a date string is passed to search (easily fixable). I'll do that. Plus, I was thinking that I should change all occurrences of |
Sounds good! |
Took me a lot longer, but pheww. finally done. :D |
Awesome! I hope to be able to review this soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally found the time to have a look :-) This is shaping up nicely!
rednotebook/gui/browser.py
Outdated
for query in search_words: | ||
self.get_find_controller().search( | ||
query, WebKit2.FindOptions.CASE_INSENSITIVE, MAX_HITS | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we stop after the first word is found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little confused here since the docs say that the search
method performs the search asynchronously. If so, would this be possible?
Previously, a search would only return results with exact matches, that is if the search string is a substring of the text in the window buffer. With this new edition, we support searching for multiple words. A result would only be shown if *all* of those words appear at least once in the text.
Hey, thanks for the review Jendrik! \o/ I believe I've addressed all of the comments. I also took the liberty and renamed the |
Closing and re-opening to trigger CI again. |
If one of the searched words is present in the current day's text, highlight it. Previously, the higlighting would only account for the last searched word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of my comments! I looked into the webkit highlighting. Now everything should work. I only have minor comments remaining.
words_contain_date = len(non_date_words) != len(words) | ||
if words_contain_date: | ||
results.append(get_text_with_dots(self.text, 0, TEXT_RESULT_LENGTH)) | ||
# If all the words matched agains the date, return. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"matched agains" -> "match"
@@ -814,17 +814,29 @@ def _get_buffer(self, key, text): | |||
def _get_buffer_for_day(self, day): | |||
return self._get_buffer(day.date, day.text) | |||
|
|||
def scroll_to_non_date_text(self, words): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new method name.
""" | ||
for word in words: | ||
# If word matches date, it probably is not present in the text. | ||
if word in str(self.day): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the pass
by inverting the if statement: if word not in str(self.day)
if word in str(self.day): | ||
pass | ||
else: | ||
super().scroll_to_text(word) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the super()
now that the child method is renamed?
@RJ722 Do you still want to pursue this? If so, it seems you'll have to merge with master first and then take care of my latest few comments. |
Summary of the changes in this pull request
Previously, a search would only return results with exact matches, that is if the search string is a substring of the text in the window buffer. With this new edition, we support searching for multiple words. A result would only be shown if all of those words appear at least once in the text.
There is a bug in there due to which highlights in the main windows aren't working properly. I have figured that one needs to have the day opened on the side, go to the search bar, and hit enter again for the highlights to work correctly. I have a hunch that this is because I've skipped the "scroll to query" part -- which I'm guessing refreshes the view? Just a hunch, I can be totally off on this.EDIT: Whenever a search result is clicked,
Day.show_day
method is called to update the view. It used theself.search_text
to take care of highlighting and scrolling to search results. I updated it to use the newself.search_queries
instead, and everything appears to be working! \o/Pull request checklist
CHANGELOG.md
including my name and issue and/or pull request number.TODO.md
.