New search - #558
Conversation
jendrikseipp
left a comment
There was a problem hiding this comment.
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. |
jendrikseipp
left a comment
There was a problem hiding this comment.
I finally found the time to have a look :-) This is shaping up nicely!
| for query in search_words: | ||
| self.get_find_controller().search( | ||
| query, WebKit2.FindOptions.CASE_INSENSITIVE, MAX_HITS | ||
| ) |
There was a problem hiding this comment.
Can we stop after the first word is found?
There was a problem hiding this comment.
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.
jendrikseipp
left a comment
There was a problem hiding this comment.
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. |
| def _get_buffer_for_day(self, day): | ||
| return self._get_buffer(day.date, day.text) | ||
|
|
||
| def scroll_to_non_date_text(self, words): |
| """ | ||
| 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.
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.
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_daymethod is called to update the view. It used theself.search_textto take care of highlighting and scrolling to search results. I updated it to use the newself.search_queriesinstead, and everything appears to be working! \o/Pull request checklist
CHANGELOG.mdincluding my name and issue and/or pull request number.TODO.md.