Skip to content
Snippets Groups Projects
Commit 623612b1 authored by George Nachman's avatar George Nachman
Browse files

Rename lastDirectoryIsRemote to lastDirectoryisUnsuitableForOldPWD and add...

Rename lastDirectoryIsRemote to lastDirectoryisUnsuitableForOldPWD and add some comments. I always find this code hard to analyze.
parent 9977ec5d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -163,7 +163,7 @@ static NSString *const SESSION_ARRANGEMENT_DIRECTORIES = @"Directories"; // Arr
static NSString *const SESSION_ARRANGEMENT_HOSTS = @"Hosts"; // Array of VT100RemoteHost
static NSString *const SESSION_ARRANGEMENT_CURSOR_GUIDE = @"Cursor Guide"; // BOOL
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY = @"Last Directory"; // NSString
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_REMOTE = @"Last Directory Is Remote"; // BOOL
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD = @"Last Directory Is Remote"; // BOOL
static NSString *const SESSION_ARRANGEMENT_SELECTION = @"Selection"; // Dictionary for iTermSelection.
static NSString *const SESSION_ARRANGEMENT_APS = @"Automatic Profile Switching"; // Dictionary of APS state.
 
Loading
Loading
@@ -232,7 +232,7 @@ static const NSUInteger kMaxHosts = 100;
@property(nonatomic) NSTimeInterval lastResize;
@property(atomic, assign) PTYSessionTmuxMode tmuxMode;
@property(nonatomic, copy) NSString *lastDirectory;
@property(nonatomic) BOOL lastDirectoryIsRemote;
@property(nonatomic) BOOL lastDirectoryIsUnsuitableForOldPWD;
@property(nonatomic, retain) VT100RemoteHost *lastRemoteHost; // last remote host at time of setting current directory
@property(nonatomic, retain) NSColor *cursorGuideColor;
@property(nonatomic, copy) NSString *badgeFormat;
Loading
Loading
@@ -1272,7 +1272,7 @@ ITERM_WEAKLY_REFERENCEABLE
if (arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY]) {
[aSession->_lastDirectory autorelease];
aSession->_lastDirectory = [arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY] copy];
aSession->_lastDirectoryIsRemote = [arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_REMOTE] boolValue];
aSession->_lastDirectoryIsUnsuitableForOldPWD = [arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD] boolValue];
}
}
 
Loading
Loading
@@ -4033,7 +4033,7 @@ ITERM_WEAKLY_REFERENCEABLE
result[SESSION_ARRANGEMENT_CURSOR_GUIDE] = @(_textview.highlightCursorLine);
if (self.lastDirectory) {
result[SESSION_ARRANGEMENT_LAST_DIRECTORY] = self.lastDirectory;
result[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_REMOTE] = @(self.lastDirectoryIsRemote);
result[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD] = @(self.lastDirectoryIsUnsuitableForOldPWD);
}
result[SESSION_ARRANGEMENT_SELECTION] =
[self.textview.selection dictionaryValueWithYOffset:-numberOfLinesDropped];
Loading
Loading
@@ -8357,7 +8357,9 @@ ITERM_WEAKLY_REFERENCEABLE
}
}
 
- (void)setLastDirectory:(NSString *)lastDirectory isRemote:(BOOL)isRemote {
// isRemote is a misnomer. It's really "is unsuitable for old PWD", since it would be YES for
// when shell integration had never been used and the lastDirectory is not updated reliably.
- (void)setLastDirectory:(NSString *)lastDirectory isUnsuitableForOldPWD:(BOOL)isUnsuitableForOldPWD {
DLog(@"Set last directory to %@", lastDirectory);
if (lastDirectory) {
[_directories addObject:lastDirectory];
Loading
Loading
@@ -8365,12 +8367,12 @@ ITERM_WEAKLY_REFERENCEABLE
}
[_lastDirectory autorelease];
_lastDirectory = [lastDirectory copy];
_lastDirectoryIsRemote = isRemote;
_lastDirectoryIsUnsuitableForOldPWD = isUnsuitableForOldPWD;
[_delegate sessionCurrentDirectoryDidChange:self];
}
 
- (NSString *)currentLocalWorkingDirectory {
if (_lastDirectoryIsRemote || _lastDirectory == nil) {
if (_lastDirectoryIsUnsuitableForOldPWD || _lastDirectory == nil) {
// Ask the kernel what the child's process's working directory is.
return [_shell getWorkingDirectory];
} else {
Loading
Loading
@@ -8400,7 +8402,10 @@ ITERM_WEAKLY_REFERENCEABLE
[[iTermShellHistoryController sharedInstance] recordUseOfPath:directory
onHost:[_screen remoteHostOnLine:line]
isChange:!isSame];
[self setLastDirectory:directory isRemote:!remoteHost.isLocalhost];
// Note that when remoteHost is nil, it's unsuitable for old PWD because
// that means shell integration hasn't been used and we have to keep
// pulling the pwd from the child process via the kernel.
[self setLastDirectory:directory isUnsuitableForOldPWD:!remoteHost.isLocalhost];
self.lastRemoteHost = remoteHost;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment