mirror of
https://github.com/textmate/textmate.git
synced 2026-01-21 04:38:13 -05:00
Files with no extension open as plain text
This is instead of asking the user.
This commit is contained in:
@@ -108,6 +108,10 @@ static std::string find_file_type (std::string const& path, io::bytes_ptr const&
|
||||
if(res == NULL_STR && effectivePath != NULL_STR)
|
||||
res = settings_for_path(effectivePath, "attr.file.unknown-type " + pathAttributes, settingsDirectory).get(kSettingsFileTypeKey, NULL_STR);
|
||||
|
||||
// check if file has no extension, if so, treat it as plain text
|
||||
if(res == NULL_STR && path::extension(effectivePath).empty())
|
||||
res = "text.plain";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,21 @@ public:
|
||||
}
|
||||
|
||||
void test_file_type ()
|
||||
{
|
||||
test::jail_t jail;
|
||||
path::set_content(jail.path("test.x-unknown"), "dummy");
|
||||
|
||||
stall_t* cb = new stall_t(NULL_STR, "x.test");
|
||||
file::open_callback_ptr sharedPtr((file::open_callback_t*)cb);
|
||||
file::open(jail.path("test.x-unknown"), osx::authorization_t(), sharedPtr);
|
||||
cb->wait();
|
||||
|
||||
TS_ASSERT_EQUALS(cb->_error, false);
|
||||
TS_ASSERT_EQUALS(cb->_file_type, "x.test");
|
||||
TS_ASSERT_EQUALS(std::string(cb->_content->begin(), cb->_content->end()), "dummy");
|
||||
}
|
||||
|
||||
void test_file_type_no_ext ()
|
||||
{
|
||||
test::jail_t jail;
|
||||
path::set_content(jail.path("test"), "dummy");
|
||||
@@ -135,18 +150,18 @@ public:
|
||||
cb->wait();
|
||||
|
||||
TS_ASSERT_EQUALS(cb->_error, false);
|
||||
TS_ASSERT_EQUALS(cb->_file_type, "x.test");
|
||||
TS_ASSERT_EQUALS(cb->_file_type, "text.plain");
|
||||
TS_ASSERT_EQUALS(std::string(cb->_content->begin(), cb->_content->end()), "dummy");
|
||||
}
|
||||
|
||||
void test_file_type_failure ()
|
||||
{
|
||||
test::jail_t jail;
|
||||
path::set_content(jail.path("test"), "dummy");
|
||||
path::set_content(jail.path("test.x-unknown"), "dummy");
|
||||
|
||||
stall_t* cb = new stall_t;
|
||||
file::open_callback_ptr sharedPtr((file::open_callback_t*)cb);
|
||||
file::open(jail.path("test"), osx::authorization_t(), sharedPtr);
|
||||
file::open(jail.path("test.x-unknown"), osx::authorization_t(), sharedPtr);
|
||||
cb->wait();
|
||||
|
||||
TS_ASSERT_EQUALS(cb->_error, true);
|
||||
|
||||
Reference in New Issue
Block a user