Permalink
Browse files

Support multiple leading non-alpha chars for camelCase to snake_case

Previously we only supported a single one, e.g. __foo_bar was turned into _fooBar (losing one leading underscore).
  • Loading branch information...
1 parent a5e3c0f commit ad23f1155753586ad6996ce1fb78d1e6c820ab5d @sorbits sorbits committed Aug 7, 2016
Showing with 3 additions and 3 deletions.
  1. +3 −3 Commands/Toggle CamelCase vs Underscore.tmCommand
@@ -33,11 +33,11 @@ end
def toggle_case(word)
case word
- when /^([^A-Za-z]?+)(?=[A-Z])/
+ when /^([^A-Za-z]*+)(?=[A-Z])/
$1 + pascalcase_to_snakecase($')
- when /^([^A-Za-z]?+)(?=.*_)/
+ when /^([^A-Za-z]*+)(?=.+_)/
$1 + snakecase_to_camelcase($')
- when /^([^A-Za-z]?+)(?=[a-z])/
+ when /^([^A-Za-z]*+)(?=[a-z])/
$1 + camelcase_to_pascalcase($')
else
word

0 comments on commit ad23f11

Please sign in to comment.