mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Change new-session -A without a session name (that is, no -s option
also) to attach to the best existing session like attach-session rather than creating a new one.
This commit is contained in:
		@@ -94,26 +94,31 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args_has(args, 's')) {
 | 
						tmp = args_get(args, 's');
 | 
				
			||||||
		newname = format_single(item, args_get(args, 's'), c, NULL,
 | 
						if (tmp != NULL) {
 | 
				
			||||||
		    NULL, NULL);
 | 
							newname = format_single(item, tmp, c, NULL, NULL, NULL);
 | 
				
			||||||
		if (!session_check_name(newname)) {
 | 
							if (!session_check_name(newname)) {
 | 
				
			||||||
			cmdq_error(item, "bad session name: %s", newname);
 | 
								cmdq_error(item, "bad session name: %s", newname);
 | 
				
			||||||
			goto fail;
 | 
								goto fail;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ((as = session_find(newname)) != NULL) {
 | 
						}
 | 
				
			||||||
			if (args_has(args, 'A')) {
 | 
						if (args_has(args, 'A')) {
 | 
				
			||||||
				retval = cmd_attach_session(item,
 | 
							if (newname != NULL)
 | 
				
			||||||
				    newname, args_has(args, 'D'),
 | 
								as = session_find(newname);
 | 
				
			||||||
				    args_has(args, 'X'), 0, NULL,
 | 
							else
 | 
				
			||||||
				    args_has(args, 'E'));
 | 
								as = item->target.s;
 | 
				
			||||||
				free(newname);
 | 
							if (as != NULL) {
 | 
				
			||||||
				return (retval);
 | 
								retval = cmd_attach_session(item, as->name,
 | 
				
			||||||
			}
 | 
								    args_has(args, 'D'), args_has(args, 'X'), 0, NULL,
 | 
				
			||||||
			cmdq_error(item, "duplicate session: %s", newname);
 | 
								    args_has(args, 'E'));
 | 
				
			||||||
			goto fail;
 | 
								free(newname);
 | 
				
			||||||
 | 
								return (retval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (newname != NULL && session_find(newname) != NULL) {
 | 
				
			||||||
 | 
							cmdq_error(item, "duplicate session: %s", newname);
 | 
				
			||||||
 | 
							goto fail;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Is this going to be part of a session group? */
 | 
						/* Is this going to be part of a session group? */
 | 
				
			||||||
	group = args_get(args, 't');
 | 
						group = args_get(args, 't');
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								input.c
									
									
									
									
									
								
							@@ -876,7 +876,7 @@ input_set_state(struct window_pane *wp, const struct input_transition *itr)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
input_parse(struct window_pane *wp)
 | 
					input_parse(struct window_pane *wp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct evbuffer		*evb = wp->event->input;
 | 
						struct evbuffer	*evb = wp->event->input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	input_parse_buffer(wp, EVBUFFER_DATA(evb), EVBUFFER_LENGTH(evb));
 | 
						input_parse_buffer(wp, EVBUFFER_DATA(evb), EVBUFFER_LENGTH(evb));
 | 
				
			||||||
	evbuffer_drain(evb, EVBUFFER_LENGTH(evb));
 | 
						evbuffer_drain(evb, EVBUFFER_LENGTH(evb));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user