mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Improve handling of empty braces in globs
We treat empty braces as literal characters though do balance them.
This commit is contained in:
@@ -171,6 +171,7 @@ namespace
|
||||
|
||||
if(parse_char("{"))
|
||||
{
|
||||
bool hasComma = false;
|
||||
node_t* localRoot = nullptr;
|
||||
while(true)
|
||||
{
|
||||
@@ -179,9 +180,21 @@ namespace
|
||||
{
|
||||
_root = oldRoot;
|
||||
_last = oldLast;
|
||||
return add_node(new node_t(node_t::kGroup, localRoot));
|
||||
if(hasComma)
|
||||
return add_node(new node_t(node_t::kGroup, localRoot));
|
||||
|
||||
delete localRoot;
|
||||
|
||||
char const* parseTo = std::exchange(it, backtrack);
|
||||
while(it != parseTo && (parse_escape() || parse_text()))
|
||||
;
|
||||
return it != parseTo ? ((it = backtrack), false) : true;
|
||||
}
|
||||
else if(!parse_char(","))
|
||||
else if(parse_char(","))
|
||||
{
|
||||
hasComma = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -250,3 +250,14 @@ void test_glob_exclusion ()
|
||||
OAK_ASSERT( path::glob_t("~html/**/*" ).does_match("/path/to/page/foo/fud.txt"));
|
||||
OAK_ASSERT( path::glob_t("~html/**/*.txt" ).does_match("/path/to/page/foo/fud.txt"));
|
||||
}
|
||||
|
||||
void test_glob_brace_expansion_match ()
|
||||
{
|
||||
OAK_ASSERT(path::glob_t("foo{bar}.txt").does_match("foo{bar}.txt"));
|
||||
OAK_ASSERT(path::glob_t("foo{,bar}.txt").does_match("foo.txt"));
|
||||
OAK_ASSERT(path::glob_t("foo{,bar}.txt").does_match("foobar.txt"));
|
||||
OAK_ASSERT(path::glob_t("foo{\\,bar}.txt").does_match("foo{,bar}.txt"));
|
||||
OAK_ASSERT(path::glob_t("{foo,{bar},baz}.txt").does_match("foo.txt"));
|
||||
OAK_ASSERT(path::glob_t("{foo,{bar},baz}.txt").does_match("{bar}.txt"));
|
||||
OAK_ASSERT(path::glob_t("{foo,{bar},baz}.txt").does_match("baz.txt"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user