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

Display the number of results for global search #44301

Merged
merged 1 commit into from
Dec 17, 2020
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
14 changes: 13 additions & 1 deletion editor/find_in_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,19 @@ void FindInFilesPanel::_on_item_edited() {
}

void FindInFilesPanel::_on_finished() {
_status_label->set_text(TTR("Search complete"));
String results_text;
int result_count = _result_items.size();
int file_count = _file_items.size();

if (result_count == 1 && file_count == 1) {
results_text = vformat(TTR("%d match in %d file."), result_count, file_count);
} else if (result_count != 1 && file_count == 1) {
results_text = vformat(TTR("%d matches in %d file."), result_count, file_count);
} else {
results_text = vformat(TTR("%d matches in %d files."), result_count, file_count);
}
Comment on lines +786 to +792
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good use case to start using the newly implemented plurals support with TTRN(): #40443.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, didn't think about it. Will look into.

Copy link
Contributor Author

@YuriSizov YuriSizov Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, this is probably not a good use case for that, because there are 2 numbers and 3 permutations between them. Not sure how TTRN would help here. I'd be able to check either result_count or file_count, but the third option would still be separate. Picking one over the other seems arbitrary, no?

Edit: Unless you propose we split them into two and TTRN each part individually?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd need to think more about it, but let's keep it simple for now and possibly improve laters. We haven't used TTRN anywhere in the translations yet, there are several places which could benefit from it.


_status_label->set_text(results_text);
update_replace_buttons();
set_progress_visible(false);
_refresh_button->show();
Expand Down