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

Enhancement/change file filtering logic #5146

Merged

Conversation

tristanhyams
Copy link
Contributor

Description

#5089 Changes the file filtering logic for match-query to AND instead of OR. This means if multiple queries are searched for within the filter field, only entries that match all queries will be displayed.

Changes

  • Added check to see whether item matches all queries. If all queries do not match, match-query will return false.
  • Updated CHANGELOG.md

Additional information

yarn test passes and yarn lint reports no errors

Tested on: MacOs 14.3.1

Copy link

boring-cyborg bot commented May 7, 2024

Thank you for opening your first PR! 🎉 We are very happy and would like to thank you very much for your contribution. If everything checks out, we'll make sure to review the PR as soon as possible and give feedback. In the meantime, to make the reviewing process as fast as possible, you can help us by checking the following things:

  • Did you follow the JSStandard coding style? - Did you comment everywhere where the necessity of a piece of code or the
    way it was implemented is not immediately obvious?
  • Did you attempt to stick as much to current coding habits as possible?
    (Note that this does not apply to pieces of code where we ourselves
    obviously violated good coding practices, which unfortunately happens
    sometimes. But please indicate this in your PR so that we know what you
    rectified!)

Furthermore, make sure that the linter does not complain, which will check your code on every new commit. If the linter task fails, make sure to run yarn lint locally and check the file eslint_report.htm which will tell you precisely what went wrong.
Stay sharp, and thanks again!

@nathanlesage
Copy link
Member

Thank you. We'll have to solve the merge conflicts with the Changelog, but in general I appreciate that you took the time to write a few lines indicating this change for users.

@kyaso Do you have time to review this PR before your vacation? It doesn't have urgent priority, but I'm booked until the end of June, and so I want to save my resources for potential urgent fixes.

Copy link
Collaborator

@kyaso kyaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the PR!

CHANGELOG.md Outdated

Previously when searching for files and workspaces in the filter field in
Zettlr, OR logic would be used, meaning that if a item matched any search query,
that item would be desplayed as a result of the search. This is not a very
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
that item would be desplayed as a result of the search. This is not a very
that item would be displayed as a result of the search. This is not a very

Copy link
Member

@nathanlesage nathanlesage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kyaso for the code review, I just have a few "formalities" regarding the changelog :)

return function (item: AnyDescriptor): boolean {
// Initialize a variable to keep track of whether all queries are matched
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Initialize a variable to keep track of whether all queries are matched

for (const q of queries) {
let queryMatched = false // Track if the current query is matched
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let queryMatched = false // Track if the current query is matched
let queryMatched = false

// The rest can only match files
if (item.type === 'file') {
// Type assertion to check if 'firstHeading' exists on file descriptors
const fileDescriptor = item as { type: 'file', tags: string[], frontmatter?: Record<string, any>, firstHeading?: string | null }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you directly coerce to MDFileDescriptor?

CHANGELOG.md Outdated

## GUI and Functionality

(Nothing here)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indicate this using Change: short description

(See previous changelog for how)

@tristanhyams
Copy link
Contributor Author

Thanks for the help @kyaso @nathanlesage. Have implemented these changes :)

@nathanlesage
Copy link
Member

Looks good, thank you! Unfortunately I'm on mobile right now and the app indicates that there are merge conflicts. I have little time to manually solve them over the weekend, but should you have time, I can merge in a calm minute so that we can mark this PR as done.

@tristanhyams
Copy link
Contributor Author

Looks good, thank you! Unfortunately I'm on mobile right now and the app indicates that there are merge conflicts. I have little time to manually solve them over the weekend, but should you have time, I can merge in a calm minute so that we can mark this PR as done.

All done, should be good to merge

@nathanlesage
Copy link
Member

Perfect! Thank you for reacting so quickly!

@nathanlesage nathanlesage merged commit fad35c4 into Zettlr:develop May 19, 2024
1 check passed
Copy link

boring-cyborg bot commented May 19, 2024

There we go, your PR got merged! Welcome to the party! 🔥

imalexhu pushed a commit to imalexhu/Zettlr that referenced this pull request May 22, 2024
imalexhu pushed a commit to imalexhu/Zettlr that referenced this pull request May 22, 2024
imalexhu pushed a commit to imalexhu/Zettlr that referenced this pull request May 22, 2024
imalexhu pushed a commit to imalexhu/Zettlr that referenced this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants