-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: reset search match counter when switching files (issue #3361) #3362
Conversation
Based off my limited understanding of the codebase, changing the file causes a action update called SET_SELECTED_FILE. Using state events instead of mutation tracking is simpler and more performant (if at all feasible that is) , and considering the design tradeoffs would be great here. Mutation is mostly intended for tracking changes in low level DOM nodes, as updating the file is a well defined state transition, hooking the search functionality on change of state would be preferable. |
Yes, initially my approach was to trigger the clearSearch function, but turns it out it wasn't that straight forward because the clearSearch function needs access to the right cm instance, and the function should ideally be called when the user switches to a different file. @raclim if there’s another reliable and better way to solve this problem, I’d be happy to refine my approach accordingly. |
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 your work on this! I removed a few extra comments that I feel could be self-explanatory from the code, but I think this overall feels good to me!
Fixes #3361
Changes:
I have added a new function named watchFileChanges:
I have also modified the startSearch function:
Another change I have made is in the SearchState constructor function where I have added the following to ensure that lastFileName is always set to the current file opened:
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123