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

[find-and-replace] Fix capitalize utility #849

Conversation

savetheclocktower
Copy link
Sponsor Contributor

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 call toUpperCase 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. to Preserve 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

  • Open a new file. Type a word on each of the first three lines.
  • Open the Find and Replace dialog and enable the regex option. Find ^ and replace with ;. Click on Find All, then on Replace All.
  • This action should fail on master and pass on this PR branch.

Release Notes

Fix certain find-and-replace scenarios when the “Preserve Case During Replace” setting is enabled.

Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

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

Easy approve from me here! Glad to see all tests passing, and that the setting key hasn't been touched when changing it's case (not that it actually needed to be).

So lets get this merged! Love a quick bug fix

@confused-Techie confused-Techie merged commit f4e4aad into pulsar-edit:master Dec 30, 2023
98 checks passed
@savetheclocktower savetheclocktower deleted the fix-find-and-replace-case-preservation branch December 30, 2023 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants