mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Fix selection behaviour when the cursor is moved backwards (ie so the selection
start is after the end).
This commit is contained in:
		
							
								
								
									
										26
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								screen.c
									
									
									
									
									
								
							@@ -234,11 +234,31 @@ screen_set_selection(struct screen *s,
 | 
				
			|||||||
	struct screen_sel	*sel = &s->sel;
 | 
						struct screen_sel	*sel = &s->sel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(&sel->cell, gc, sizeof sel->cell);
 | 
						memcpy(&sel->cell, gc, sizeof sel->cell);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	sel->flag = 1;
 | 
						sel->flag = 1;
 | 
				
			||||||
	if (ey < sy || (sy == ey && ex < sx)) {
 | 
					
 | 
				
			||||||
 | 
						/* starting line < ending line -- downward selection. */
 | 
				
			||||||
 | 
						if (sy < ey) {
 | 
				
			||||||
 | 
							sel->sx = sx; sel->sy = sy;
 | 
				
			||||||
 | 
							sel->ex = ex; sel->ey = ey;
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* starting line > ending line -- upward selection. */
 | 
				
			||||||
 | 
						if (sy > ey) {
 | 
				
			||||||
 | 
							if (sx > 0) {
 | 
				
			||||||
 | 
								sel->sx = ex; sel->sy = ey;
 | 
				
			||||||
 | 
								sel->ex = sx - 1; sel->ey = sy;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								sel->sx = ex; sel->sy = ey;
 | 
				
			||||||
 | 
								sel->ex = -1; sel->ey = sy - 1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* starting line == ending line. */
 | 
				
			||||||
 | 
						if (ex < sx) {
 | 
				
			||||||
		sel->sx = ex; sel->sy = ey;
 | 
							sel->sx = ex; sel->sy = ey;
 | 
				
			||||||
		sel->ex = sx; sel->ey = sy;
 | 
							sel->ex = sx - 1; sel->ey = sy;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		sel->sx = sx; sel->sy = sy;
 | 
							sel->sx = sx; sel->sy = sy;
 | 
				
			||||||
		sel->ex = ex; sel->ey = ey;
 | 
							sel->ex = ex; sel->ey = ey;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user