mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Fix how popup height is calculated to take embedded newlines into account.
This commit is contained in:
		
							
								
								
									
										20
									
								
								popup.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								popup.c
									
									
									
									
									
								
							@@ -349,6 +349,22 @@ popup_job_complete_cb(struct job *job)
 | 
			
		||||
		server_client_clear_overlay(pd->c);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
u_int
 | 
			
		||||
popup_height(u_int nlines, const char **lines)
 | 
			
		||||
{
 | 
			
		||||
	char	*copy, *next, *loop;
 | 
			
		||||
	u_int	 i, height = 0;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < nlines; i++) {
 | 
			
		||||
		copy = next = xstrdup(lines[i]);
 | 
			
		||||
		while ((loop = strsep(&next, "\n")) != NULL)
 | 
			
		||||
			height++;
 | 
			
		||||
		free(copy);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
u_int
 | 
			
		||||
popup_width(struct cmdq_item *item, u_int nlines, const char **lines,
 | 
			
		||||
    struct client *c, struct cmd_find_state *fs)
 | 
			
		||||
@@ -372,8 +388,8 @@ popup_width(struct cmdq_item *item, u_int nlines, const char **lines,
 | 
			
		||||
				width = tmpwidth;
 | 
			
		||||
			free(tmp);
 | 
			
		||||
		}
 | 
			
		||||
		free(copy);
 | 
			
		||||
	}
 | 
			
		||||
	free(copy);
 | 
			
		||||
 | 
			
		||||
	format_free(ft);
 | 
			
		||||
	return (width);
 | 
			
		||||
@@ -394,8 +410,6 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
 | 
			
		||||
		return (-1);
 | 
			
		||||
	if (c->tty.sx < sx || c->tty.sy < sy)
 | 
			
		||||
		return (-1);
 | 
			
		||||
	if (nlines > sy - 2)
 | 
			
		||||
		nlines = sy - 2;
 | 
			
		||||
 | 
			
		||||
	pd = xcalloc(1, sizeof *pd);
 | 
			
		||||
	pd->item = item;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user