datasert / vscode-texty

Sweet set of Text utilities for VS Code
https://marketplace.visualstudio.com/items?itemName=datasert.vscode-texty
Apache License 2.0
7 stars 4 forks source link

convertToSentenceCase converts only the first character #19

Open ryan-carpenter opened 8 months ago

ryan-carpenter commented 8 months ago

The convertToSentenceCase function takes a string and converts the first character of the first word to uppercase but does not convert uppercase characters to lowercase.

String Result Expected Success?
example one Example one Example one
Example two Example two Example two
Example Three Example Three Example three
EXample four E Xample four Example four
EXAMPLE FIVE EXAMPLE FIVE Example five

Workaround: convert the string to lowercase using Texty Convert to Lowercase or VSCode Transform to Lowercase before using Texty Convert to Sentence Case.

Possible solution: modify Texty convertToSentenceCase to include toLower() before upperFirst().

https://github.com/datasert/vscode-texty/blob/fd132cd83e3f02805dc05e632a31ef3e4adeffcf/src/modules/cases.ts#L21

https://github.com/datasert/vscode-texty/blob/fd132cd83e3f02805dc05e632a31ef3e4adeffcf/src/modules/cases.ts#L65