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

Remember search text in Find/Replace in Files dialog #89085

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions editor/find_in_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,24 @@ FindInFilesDialog::FindInFilesDialog() {
}

void FindInFilesDialog::set_search_text(const String &text) {
_search_text_line_edit->set_text(text);
_on_search_text_modified(text);
if (_mode == SEARCH_MODE) {
if (!text.is_empty()) {
_search_text_line_edit->set_text(text);
_on_search_text_modified(text);
}
callable_mp((Control *)_search_text_line_edit, &Control::grab_focus).call_deferred();
_search_text_line_edit->select_all();
} else if (_mode == REPLACE_MODE) {
if (!text.is_empty()) {
_search_text_line_edit->set_text(text);
callable_mp((Control *)_replace_text_line_edit, &Control::grab_focus).call_deferred();
_replace_text_line_edit->select_all();
_on_search_text_modified(text);
} else {
callable_mp((Control *)_search_text_line_edit, &Control::grab_focus).call_deferred();
_search_text_line_edit->select_all();
}
KoBeWi marked this conversation as resolved.
Show resolved Hide resolved
}
}

void FindInFilesDialog::set_replace_text(const String &text) {
Expand Down Expand Up @@ -464,9 +480,6 @@ void FindInFilesDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
// Doesn't work more than once if not deferred...
callable_mp((Control *)_search_text_line_edit, &Control::grab_focus).call_deferred();
_search_text_line_edit->select_all();
// Extensions might have changed in the meantime, we clean them and instance them again.
for (int i = 0; i < _filters_container->get_child_count(); i++) {
_filters_container->get_child(i)->queue_free();
Expand Down
Loading