mirror of
https://github.com/textmate/textmate.git
synced 2026-01-20 20:27:59 -05:00
Creating empty glob_list_t matches everything
This is more than creating a glob_list_t containing just ‘*’, as the latter does not match hidden files, so it is more like ‘{*,.*}’, which is a bit arcane, so I think it’s better to allow using an empty list in cases where you wish to match everything (but the API accepts a glob list for filtering purposes).
This commit is contained in:
@@ -241,6 +241,9 @@ namespace path
|
||||
|
||||
bool glob_list_t::exclude (std::string const& path, kPathItemType itemType, bool defaultResult) const
|
||||
{
|
||||
if(_globs.empty())
|
||||
return false;
|
||||
|
||||
for(auto record : _globs)
|
||||
{
|
||||
if((itemType == kPathItemAny || record.item_type == kPathItemAny || itemType == record.item_type) && record.glob.does_match(path))
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
class GlobListTests : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_empty_glob_list ()
|
||||
{
|
||||
path::glob_list_t globs;
|
||||
TS_ASSERT(globs.include("foo"));
|
||||
TS_ASSERT(globs.include("bar"));
|
||||
TS_ASSERT(globs.include(".foo"));
|
||||
TS_ASSERT(globs.include(".bar"));
|
||||
}
|
||||
|
||||
void test_non_empty_glob_list ()
|
||||
{
|
||||
path::glob_list_t globs("*");
|
||||
TS_ASSERT(globs.include("foo"));
|
||||
TS_ASSERT(globs.include("bar"));
|
||||
TS_ASSERT(globs.exclude(".foo"));
|
||||
TS_ASSERT(globs.exclude(".bar"));
|
||||
}
|
||||
|
||||
void test_glob_list ()
|
||||
{
|
||||
path::glob_list_t globs;
|
||||
|
||||
Reference in New Issue
Block a user