Skip to content

Commit

Permalink
Fix bug with preserve case implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Komediruzecki authored and Rokt33r committed May 4, 2021
1 parent c0d5fcd commit 341d278
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/organisms/LocalReplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ const LocalReplace = ({
markerRange.from,
markerRange.to
)

if (foundMarkText.length >= 1 && preservingCaseReplace) {
// if first character was upper case - set the replacement to upper case too
const foundItemFirstLetterIsUpperCase =
foundMarkText.charAt(0) != foundMarkText.charAt(0).toLowerCase()
const preservedFirstCharacterCase = foundItemFirstLetterIsUpperCase
? replaceQuery.charAt(0).toUpperCase()
: replaceQuery.charAt(0).toLowerCase()
// if first character was upper case - set the replacement to upper case too and vice versa
codeMirror.replaceRange(
foundMarkText.charAt(0) + replaceQuery.substr(1),
preservedFirstCharacterCase + replaceQuery.substr(1),
markerRange.from,
markerRange.to
)
Expand Down

0 comments on commit 341d278

Please sign in to comment.