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

[tmux integration] Store "none" for the tab color when tab color is off for a...

[tmux integration] Store "none" for the tab color when tab color is off for a session. This fixes a bug where new tmux sessions didn't use the profile's color. Uninitialized (which is now indicated as an unset tab color) should (and now does) mean to use the profile's value. "none" means no color. Otherwise it'll be a #hex value.

Issue 6320
parent 53614836
No related branches found
No related tags found
No related merge requests found
Loading
@@ -196,6 +196,10 @@ static NSString *const kVariableKeySessionCreationTimeString = @"session.creatio
Loading
@@ -196,6 +196,10 @@ static NSString *const kVariableKeySessionCreationTimeString = @"session.creatio
static NSString *const kVariableKeySessionPID = @"iterm2.pid"; static NSString *const kVariableKeySessionPID = @"iterm2.pid";
static NSString *const kVariableKeySessionAutoLogID = @"session.autoLogId"; static NSString *const kVariableKeySessionAutoLogID = @"session.autoLogId";
   
// Value for SESSION_ARRANGEMENT_TMUX_TAB_COLOR that means "don't use the
// default color from the tmux profile; this tab should have no color."
static NSString *const iTermTmuxTabColorNone = @"none";
// Maps Session GUID to saved contents. Only live between window restoration // Maps Session GUID to saved contents. Only live between window restoration
// and the end of startup activities. // and the end of startup activities.
static NSMutableDictionary *gRegisteredSessionContents; static NSMutableDictionary *gRegisteredSessionContents;
Loading
@@ -963,7 +967,8 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -963,7 +967,8 @@ ITERM_WEAKLY_REFERENCEABLE
} }
if ([arrangement objectForKey:SESSION_ARRANGEMENT_TMUX_PANE]) { if ([arrangement objectForKey:SESSION_ARRANGEMENT_TMUX_PANE]) {
// This is a tmux arrangement. // This is a tmux arrangement.
NSDictionary *tabColorDict = [ITAddressBookMgr encodeColor:[NSColor colorFromHexString:arrangement[SESSION_ARRANGEMENT_TMUX_TAB_COLOR]]]; NSString *colorString = arrangement[SESSION_ARRANGEMENT_TMUX_TAB_COLOR];
NSDictionary *tabColorDict = [ITAddressBookMgr encodeColor:[NSColor colorFromHexString:colorString]];
if (tabColorDict) { if (tabColorDict) {
// We're restoring a tmux arrangement that specifies a tab color. // We're restoring a tmux arrangement that specifies a tab color.
if (![iTermProfilePreferences boolForKey:KEY_USE_TAB_COLOR inProfile:theBookmark] || if (![iTermProfilePreferences boolForKey:KEY_USE_TAB_COLOR inProfile:theBookmark] ||
Loading
@@ -973,7 +978,8 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -973,7 +978,8 @@ ITERM_WEAKLY_REFERENCEABLE
theBookmark = [theBookmark dictionaryBySettingObject:@YES forKey:KEY_USE_TAB_COLOR]; theBookmark = [theBookmark dictionaryBySettingObject:@YES forKey:KEY_USE_TAB_COLOR];
needDivorce = YES; needDivorce = YES;
} }
} else if ([iTermProfilePreferences boolForKey:KEY_USE_TAB_COLOR inProfile:theBookmark]) { } else if ([colorString isEqualToString:iTermTmuxTabColorNone] &&
[iTermProfilePreferences boolForKey:KEY_USE_TAB_COLOR inProfile:theBookmark]) {
// There was no tab color but the tmux profile specifies one. Disable it and divorce. // There was no tab color but the tmux profile specifies one. Disable it and divorce.
theBookmark = [theBookmark dictionaryBySettingObject:@NO forKey:KEY_USE_TAB_COLOR]; theBookmark = [theBookmark dictionaryBySettingObject:@NO forKey:KEY_USE_TAB_COLOR];
needDivorce = YES; needDivorce = YES;
Loading
@@ -3444,7 +3450,8 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -3444,7 +3450,8 @@ ITERM_WEAKLY_REFERENCEABLE
tabColorDict = nil; tabColorDict = nil;
} }
NSColor *tabColor = [ITAddressBookMgr decodeColor:tabColorDict]; NSColor *tabColor = [ITAddressBookMgr decodeColor:tabColorDict];
[self.tmuxController setTabColorString:[tabColor hexString] forWindowPane:_tmuxPane]; [self.tmuxController setTabColorString:tabColor ? [tabColor hexString] : iTermTmuxTabColorNone
forWindowPane:_tmuxPane];
} }
} }
   
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