-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Desktop: fix #3153 #3154
Desktop: fix #3153 #3154
Conversation
any update? |
hey @ylc395 . I had a look and have some observations. Since we are fixing GoToAything, I don't think parsedQuery will have any key other than '_' Wouldn't adding a default fields attribute in the results variable received in GoToAnything fix this problem? |
@naviji thank you for your review
If you type something like |
@naviji You're right, there is no way for basic search to get exact fields which match keyword, but at least, if keyword is not found in title, we can know that it is in body field, and can highlight the matched words in result. |
const testTitle = regex => new RegExp(regex, 'ig').test(row.title); | ||
const matchedFields = { | ||
title: parsedQuery.keys.includes('title') || valueRegexs.some(testTitle), | ||
body: true, // always assume that keywords appear in body to attempt to highlight keyword | ||
}; | ||
|
||
row.fields = Object.keys(pickBy(matchedFields, identity)); | ||
row.weight = 0; |
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.
Now that I think about it, I don't see where the title field is used in GoToAnything.
Since 'body' is in the fields by default, it doesn't matter if we include 'title' or not. Could you look into that?
If we don't need to put in the effort to set the title field correctly everything becomes very easy. Only two lines of code are needed.
row.fields = ['body']
row.weight = 0
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 want to support searching specific field in GotoAnything. For example, when I type title:测试
, I don't want to highlight body so GoToAnything doesn't need to do that, just like searching with English. See my latest commit below, fix another bug
switch to another local branch. See #3180 |
Please see the discussion in #3153