Open smoelius opened 2 years ago
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).
TMPG_M2HH3
TmpgM2Hh3
The proposed fix is to always force lowercase in the else case, i.e., essentially eliminate the if prev.is_uppercase() check.
if prev.is_uppercase()
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 toTmpgM2Hh3
(playground).The proposed fix is to always force lowercase in the else case, i.e., essentially eliminate the
if prev.is_uppercase()
check.