-
Notifications
You must be signed in to change notification settings - Fork 558
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 search selections when content is changed #2846
base: trunk
Are you sure you want to change the base?
Conversation
Thank you. I didn't catch that case. I'm not sure how to proceed here when the content changes and there is a search selection. Right now we store the index in the array of matched search results. So if the content changes that index may not be valid anymore. In that case, do we reset the selection to the first search match? Should we also store the range for the current search match selection? Then if the content changes we could try to select the closest match to the previously selected range? The case I tried to address here was pretty easy. If the selected index is higher than the number of matches we have, select the last one instead, but the other cases seem more difficult. |
Hmm. I would say we reset it to the nearest valid search selection if we can't figure out what was actually selected before the content changed. I am honestly not sure how that would feel. We could try resetting to the first selection too and just see what feels better. I think it feels buggy to have it still say "8 of 12" or whatever without a selection being highlighted at all, so we should try to handle that case somehow.
This is a cool idea. |
Removed the reviewers on this PR until we are ready to take another look. |
We need to see if we can still reproduce this, I refactored the search decorations in #3183 and I believe they are being recalculated when the model changes, but I'm not sure if the selected index is being properly invalidated. |
it looks like this is fairly stale, but just in case, it would be nice to see if it can be approached through middleware instead of as an action dispatched from the view component. I'm sure there are a number of edges where things jump around unexpectedly because of this. |
Hi! |
Fix
Fixes #2809
Update:
There are still a few issues search selection when the content of the note has changed. I've changed this back to a draft to come back and address sometime in the future.
Currently, when you search for a term, change the selected search match, then edit the content to remove a search match the selected search indicators can become incorrect. For example, it could say you are at match 4 of 3.
This corrects that.
Test
word
in itword
word
until one remains ~> the indicator will show 5 of 1Release