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

Desktop: fix #3153 #3154

Closed
wants to merge 4 commits into from
Closed

Desktop: fix #3153 #3154

wants to merge 4 commits into from

Conversation

ylc395
Copy link
Contributor

@ylc395 ylc395 commented Apr 30, 2020

Please see the discussion in #3153

@laurent22 laurent22 added the high High priority issues label Apr 30, 2020
@ylc395
Copy link
Contributor Author

ylc395 commented May 6, 2020

any update?

@ylc395 ylc395 requested a review from laurent22 May 6, 2020 05:42
@naviji
Copy link
Contributor

naviji commented May 7, 2020

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 '_'
The bug seems to be that the fields attribute is missing.

Wouldn't adding a default fields attribute in the results variable received in GoToAnything fix this problem?
results = results.map(r => Object.assign({fields: []}, r))
What do you think?

@ylc395
Copy link
Contributor Author

ylc395 commented May 7, 2020

@naviji thank you for your review

Since we are fixing GoToAything, I don't think parsedQuery will have any key other than '_'
The bug seems to be that the fields attribute is missing.

If you type something like title:xxxx in GoToAnything, the parsedQuery will get a title key.
图片

@naviji
Copy link
Contributor

naviji commented May 7, 2020

That's true. Thanks for clearing that up!

The fields attribute is used to format the output, right?

So what you are aiming to do is make the output of GoToAnything work similarly like English for Chinese, Japanese, Korean, and Thai.

Here is a test case that fails.
bug1

bug3

bug2
bug4

이야기
이야기 소년 이야기

I'd expect both 이야기 to be highlighted just like both story is highlighted.
If not, I don't understand why we go to the trouble of finding the fields.

@ylc395
Copy link
Contributor Author

ylc395 commented May 7, 2020

@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.
图片

ReactNativeClient/lib/services/SearchEngine.js Outdated Show resolved Hide resolved
ReactNativeClient/lib/services/SearchEngine.js Outdated Show resolved Hide resolved
Comment on lines 244 to 251
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;
Copy link
Contributor

@naviji naviji May 8, 2020

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

Copy link
Contributor Author

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

@ylc395
Copy link
Contributor Author

ylc395 commented May 9, 2020

switch to another local branch. See #3180

@ylc395 ylc395 closed this May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high High priority issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants