-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Search terms are now highlighted when the bar opens with a selection. #82707
Search terms are now highlighted when the bar opens with a selection. #82707
Conversation
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.
Nitpick: dir
makes me think of a directory rather than direction. Otherwise, looks excellent!
1c098f8
to
c1b4e66
Compare
Thanks for the feedback - I went ahead and amended it. |
editor/code_editor.cpp
Outdated
@@ -536,6 +528,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { | |||
search_text->set_caret_column(search_text->get_text().length()); | |||
} | |||
|
|||
_update_flags(false); |
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 we just add a _search_text_changed(get_search_text())
call after search_text->set_text(text_editor->get_selected_text(0))
? Force doing a search when the search bar is shown. I did some test locally.
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.
That would clean the code up but it triggers a search_current unnecessarily, since the the first search match is already selected in this case. I figured that's why the stuff that was already here was inlined in the first place, so I stuck with that.
If you guys think that slight inefficiency is worth the cleaner code I can change it (it doesn't affect the resulting behavior).
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.
@jsjtxietian what do you think about my post above?
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.
Ah sorry for the late reply. IMHO both are fine, it's a choice between a little readability and performance. I slightly perfer my suggestion because it introduces less change which could potentially introduce less bug.
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 made that change, with the exception that I left the _search_text_changed
where the existing result-updating code was in the not-empty check, to avoid doing it unnecessarily and minimize the change.
40118f1
to
4d520a2
Compare
Thanks, I didn't realize I needed to force push after a rebase. |
e0cb60a
to
6c199d9
Compare
6c199d9
to
4d8ac66
Compare
This is achieved by triggering a search when the bar opens. This is slightly inefficient but cleanly updates everything that's dependent on the search and reduces code duplication.
4d8ac66
to
0d7db93
Compare
Thanks! |
Previously, the code editor only updated the text highlights when a search was made, but opening the search bar with a selection does not go through that code path because the first result is already selected.
This is a fix for #82706.
Bugsquad edit: