mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Let DocumentController provide SCM scopes
This commit is contained in:
@@ -921,7 +921,24 @@ namespace
|
||||
|
||||
- (NSString*)scopeAttributes
|
||||
{
|
||||
return self.pathAttributes;
|
||||
if(!_scmInfo)
|
||||
return self.pathAttributes;
|
||||
|
||||
NSMutableString* res = [self.pathAttributes mutableCopy];
|
||||
|
||||
auto vars = _scmInfo->variables();
|
||||
auto iter = vars.find("TM_SCM_BRANCH");
|
||||
if(iter != vars.end())
|
||||
[res appendFormat:@" attr.scm.branch.%s", iter->second.c_str()];
|
||||
|
||||
if(self.representedFile)
|
||||
{
|
||||
scm::status::type status = _scmInfo->status(to_s(self.representedFile));
|
||||
if(status != scm::status::unknown)
|
||||
[res appendFormat:@" attr.scm.status.%s", to_s(status).c_str()];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// ==============
|
||||
|
||||
@@ -92,23 +92,6 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void scm_attributes (std::string const& path, std::string const& dir, std::vector<std::string>& res)
|
||||
{
|
||||
if(scm::info_ptr info = scm::info(dir))
|
||||
{
|
||||
auto scmVariables = info->variables();
|
||||
if(scmVariables.find("TM_SCM_BRANCH") != scmVariables.end())
|
||||
res.push_back("attr.scm.branch." + scmVariables["TM_SCM_BRANCH"]);
|
||||
|
||||
if(path != NULL_STR)
|
||||
{
|
||||
scm::status::type status = info->status(path);
|
||||
if(status != scm::status::unknown)
|
||||
res.push_back("attr.scm.status." + to_s(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace file
|
||||
@@ -148,7 +131,6 @@ namespace file
|
||||
|
||||
std::string const parentDir = dir == NULL_STR ? path::parent(path) : dir;
|
||||
directory_attributes(parentDir, res);
|
||||
scm_attributes(path, parentDir, res);
|
||||
|
||||
res.push_back(settings_for_path(path, text::join(res, " "), parentDir).get(kSettingsScopeAttributesKey, ""));
|
||||
res.erase(std::remove(res.begin(), res.end(), ""), res.end());
|
||||
|
||||
Reference in New Issue
Block a user