mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Titlecase does not preserve case when everything is uppercase
This commit is contained in:
@@ -144,7 +144,7 @@ struct expand_visitor : boost::static_visitor<void>
|
||||
|
||||
static std::string capitalize (std::string const& src)
|
||||
{
|
||||
return format_string::replace(format_string::replace(src, "\\b\\p{Upper}\\p{^Upper}+?\\b", "${0:/downcase}"), "^([\\W\\d]*)(\\w[-\\w]*)|\\b((?!(?:else|from|over|then|when)\\b)\\w[-\\w]{3,}|\\w[-\\w]*[\\W\\d]*$)", "${1:?$1\\u$2:\\u$0}");
|
||||
return format_string::replace(format_string::replace(src, "\\A\\p{^Lower}+\\z|\\b\\p{Upper}\\p{^Upper}+?\\b", "${0:/downcase}"), "^([\\W\\d]*)(\\w[-\\w]*)|\\b((?!(?:else|from|over|then|when)\\b)\\w[-\\w]{3,}|\\w[-\\w]*[\\W\\d]*$)", "${1:?$1\\u$2:\\u$0}");
|
||||
}
|
||||
|
||||
static std::string asciify (std::string const& org)
|
||||
|
||||
@@ -20,6 +20,8 @@ void test_capitalize ()
|
||||
OAK_ASSERT_EQ(replace("# 2014-08-22: it works now again #", ".+", "${0:/capitalize}"), "# 2014-08-22: It Works now Again #");
|
||||
OAK_ASSERT_EQ(replace("my NSTableView subclass", ".+", "${0:/capitalize}"), "My NSTableView Subclass");
|
||||
OAK_ASSERT_EQ(replace("This Is The Wrong", ".+", "${0:/capitalize}"), "This is the Wrong");
|
||||
OAK_ASSERT_EQ(replace("THIS IS THE WRONG", ".+", "${0:/capitalize}"), "This is the Wrong");
|
||||
OAK_ASSERT_EQ(replace("RSA", ".+", "${0:/capitalize}"), "Rsa");
|
||||
}
|
||||
|
||||
void test_variables ()
|
||||
|
||||
Reference in New Issue
Block a user