-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Show match index in place of match count #8591
Conversation
src/search/FindReplace.js
Outdated
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.
Can't this just be var index = resultSet.indexOf(cursor) ?
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.
@JeffryBooher I think it can't, because it's not the same object by === standards. _.findIndex() does a deep comparison instead.
|
Seems to work for normal find/replace from the find bar but:
|
|
done with initial review |
src/search/FindReplace.js
Outdated
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.
Might want to add a note here that findNext()'s call to _showMatchIndex() is what upates this label in the other case -- and that any call to updateResultSet() is guaranteed to be followed by a call to findNext() (unless there's no query, in which case we've already cleared the find count label above).
src/search/FindReplace.js
Outdated
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.
@RaymondLim This might have performance implications though -- now it's O(n) every time you invoke Find Next. Might not be noticeable most of the time, but it's not ideal. Do you think it's worth trying my earlier suggestion? If you use the previous matchIndex as the starting point (and then search in the direction the caller passes in as a hint), then it will remain O(1) for most cases.
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'm not sure I understand your suggestion of using previous matchIndex as the starting point. So you're not suggesting to use _.findIndex() which does not take another argument to use the prev match index. Also, as I mentioned in previous comment as an update, this change does uncover one issue that is in my prior implementation for replace scenario. So can you show me the code that you're suggesting? And does your suggestion work for replace scenario where the index does not change after replacement, but the total match count does reduce one.
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.
@peterflynn I think I found a solution that is O(1) for most of the subsequent updates of the match index.
Conflicts: src/search/FindReplace.js
|
@JeffryBooher and @peterflynn Ready for re-review. |
src/search/FindReplace.js
Outdated
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.
we should make this searchingBackwards to avoid rev being confused with something else like revision
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 was using the same variable from the caller function, but I agree that rev can be misleading.
|
@RaymondLim just the one nit on changing |
|
Ready for re-review. |
|
Looks good. Merging |
Show match index in place of match count
This is the implementation of https://trello.com/c/0GXqt5GF/1089-s-find-next-indicate-current-match-index.