fix: enable texts of search
related commnds to show in plural form when mutli files are selected.
#1688
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Previously, when pressing the
c
key, the text displayed was always in singular form, even when multiple files were selected:Solution
After this fix, when multiple files are selected and the
c
key is pressed, the nouns are converted to plural form:The original singular form is maintained if only one file is selected (or hovered).
Implementation Details
Enabled the
desc
text field inkeymap.toml
to support formats likewol{ves|f}
orname{s}
, accommodating both regular and irregular plural forms.The new system works as follows:
a. Matches content inside
{}
and splits it.b. For plural form: Uses the first element of the split to replace the whole
{}
.Example:
wol{ves|f}
=>wolves
,name{s}
=>names
c. For singular form:
|
), removes the entire{}
.Example:
name{s}
=>name
,wol{ves|f}
=>wolf
Updated the logic to call
selected_or_hovered
in advance when thec
key is pressed, ensuring accurate capture of selected file count in theWhich
window.For the
Help
window, the default plural form is used to display help information.Additional Notes
I'd be much appericiated if you can provide me any feedback. To be honest, this PR is slightly more complicated than I initially though, But it helps me know lots more cool features of this project.