paste icon indicating copy to clipboard operation
paste copied to clipboard

Fix camel num-upper boundary handling

Open smoelius opened this issue 3 years ago • 0 comments

Ths PR fixes a problem affecting numbers/uppercase-letter boundaries in identifiers being converted to camel case.

The following else-if case would apply and force the current character to lowercase only if the previous character was uppercase: https://github.com/dtolnay/paste/blob/c71982e1cc08c8a8fafa17f283ef740a3138e561/src/segment.rs#L204-L208 If the previous character was a number, the above case would not apply and the current character would be pushed unchanged: https://github.com/dtolnay/paste/blob/c71982e1cc08c8a8fafa17f283ef740a3138e561/src/segment.rs#L208-L210 This would cause an input string like TMPG_M2HH3 to be incorrectly converted to TmpgM2Hh3 (playground).

The proposed fix is to always force lowercase in the else case, i.e., essentially eliminate the if prev.is_uppercase() check.

smoelius avatar Jun 19 '22 00:06 smoelius