mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Correctly skip existing numbers when generating the name for a new
session.
This commit is contained in:
		
							
								
								
									
										15
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								session.c
									
									
									
									
									
								
							@@ -119,11 +119,18 @@ session_create(const char *name, const char *cmd, const char *cwd,
 | 
			
		||||
	s->sx = sx;
 | 
			
		||||
	s->sy = sy;
 | 
			
		||||
 | 
			
		||||
	s->idx = next_session++;
 | 
			
		||||
	if (name != NULL)
 | 
			
		||||
	if (name != NULL) {
 | 
			
		||||
		s->name = xstrdup(name);
 | 
			
		||||
	else
 | 
			
		||||
		xasprintf(&s->name, "%u", s->idx);
 | 
			
		||||
		s->idx = next_session++;
 | 
			
		||||
	} else {
 | 
			
		||||
		s->name = NULL;
 | 
			
		||||
		do {
 | 
			
		||||
			s->idx = next_session++;
 | 
			
		||||
			if (s->name != NULL)
 | 
			
		||||
				xfree (s->name);
 | 
			
		||||
			xasprintf(&s->name, "%u", s->idx);
 | 
			
		||||
		} while (RB_FIND(sessions, &sessions, s) != NULL);
 | 
			
		||||
	}
 | 
			
		||||
	RB_INSERT(sessions, &sessions, s);
 | 
			
		||||
 | 
			
		||||
	if (cmd != NULL) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user