[find-and-replace] Fix capitalize
utility
#849
Merged
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.
Fixes discussions/244.
Identify the Bug
A utility function in the
find-and-replace
package for capitalizing strings was doomed to fail when given an empty string as input. It assumed it could calltoUpperCase
on the string’s first character.Nobody noticed this because it doesn’t happen unless the user enables the Preserve Case During Replace option (which is
false
by default).Description of the Change
Return empty strings as-is, for there is nothing to capitalize.
I also took this opportunity to rename the setting from
Preserve case during replace.
toPreserve Case During Replace
. I don’t love How We Title-Case Every Single Setting, but if we’re going to do it, we should be consistent about it.Alternate Designs
I really didn’t think too hard about this one.
Possible Drawbacks
We provide such a smooth and bug-free experience that Pulsar users take us completely for granted.
Verification Process
^
and replace with;
. Click on Find All, then on Replace All.Release Notes
Fix certain find-and-replace scenarios when the “Preserve Case During Replace” setting is enabled.