Recreate SCM info when re-opening file chooser

This is required for showing SCM status for “Open Files”. Previously, closing the file chooser with “Open Files” selected and re-opening it, would not have SCM info for the open files.
This commit is contained in:
Allan Odgaard
2014-02-27 11:30:45 +07:00
parent 56ae96982d
commit 2389e2c589

View File

@@ -271,6 +271,13 @@ static path::glob_list_t globs_for_path (std::string const& path)
return self;
}
- (void)showWindow:(id)sender
{
if(_path && !_scmInfo)
[self obtainSCMInfo];
[super showWindow:sender];
}
- (void)windowWillClose:(NSNotification*)aNotification
{
[self shutdownScanner];
@@ -474,6 +481,9 @@ static path::glob_list_t globs_for_path (std::string const& path)
return;
_path = aString;
_scmInfo.reset();
[self obtainSCMInfo];
if(_sourceIndex != kFileChooserAllSourceIndex)
return;
@@ -485,13 +495,6 @@ static path::glob_list_t globs_for_path (std::string const& path)
[self addRecordsForDocuments:_openDocuments];
settings_t const settings = settings_for_path(NULL_STR, "", to_s(_path));
_scanner = std::make_shared<document::scanner_t>(to_s(_path), globs_for_path(to_s(_path)), settings.get(kSettingsFollowSymbolicLinksKey, false), false, false);
_scmInfo = scm::info(to_s(_path));
if(_scmInfo)
{
_scmInfo->add_callback(^(scm::info_t const& info){
[self updateSCMStatus];
});
}
_pollInterval = 0.01;
_pollTimer = [NSTimer scheduledTimerWithTimeInterval:_pollInterval target:self selector:@selector(fetchScannerResults:) userInfo:nil repeats:NO];
@@ -500,6 +503,17 @@ static path::glob_list_t globs_for_path (std::string const& path)
[self updateWindowTitle];
}
- (scm::info_ptr)obtainSCMInfo
{
if(!_scmInfo && (_scmInfo = scm::info(to_s(_path))))
{
_scmInfo->add_callback(^(scm::info_t const& info){
[self updateSCMStatus];
});
}
return _scmInfo;
}
- (void)reload
{
switch(_sourceIndex)