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

Fix camel num-upper boundary handling #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smoelius
Copy link

@smoelius smoelius commented Jun 19, 2022

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:

paste/src/segment.rs

Lines 204 to 208 in c71982e

} else if prev.is_uppercase() {
for chl in ch.to_lowercase() {
acc.push(chl);
}
} else {

If the previous character was a number, the above case would not apply and the current character would be pushed unchanged:

paste/src/segment.rs

Lines 208 to 210 in c71982e

} else {
acc.push(ch);
}

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.

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.

None yet

1 participant