selection: explicitly set direction when right-click extending

Fixes an issue where right-click-and-dragging to extend a selection
caused one cell being removed from the selection.

Closes #180
This commit is contained in:
Daniel Eklöf 2020-11-04 19:01:59 +01:00
parent c512dc4490
commit 66f846d723
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 8 additions and 0 deletions

View file

@ -31,6 +31,8 @@
argument in `ioctl(3)` is an `int` (for example: linux/ppc64). argument in `ioctl(3)` is an `int` (for example: linux/ppc64).
* Crash when using the mouse in alternate scroll mode in an unfocused * Crash when using the mouse in alternate scroll mode in an unfocused
window (https://codeberg.org/dnkl/foot/issues/179). window (https://codeberg.org/dnkl/foot/issues/179).
* Character dropped from selection when "right-click-hold"-extending a
selection (https://codeberg.org/dnkl/foot/issues/180).
## 1.5.2 ## 1.5.2

View file

@ -475,17 +475,20 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
assert(start->row < end->row || start->col < end->col); assert(start->row < end->row || start->col < end->col);
struct coord new_start, new_end; struct coord new_start, new_end;
enum selection_scroll_direction direction;
if (row < start->row || (row == start->row && col < start->col)) { if (row < start->row || (row == start->row && col < start->col)) {
/* Extend selection to start *before* current start */ /* Extend selection to start *before* current start */
new_start = *end; new_start = *end;
new_end = (struct coord){col, row}; new_end = (struct coord){col, row};
direction = SELECTION_LEFT;
} }
else if (row > end->row || (row == end->row && col > end->col)) { else if (row > end->row || (row == end->row && col > end->col)) {
/* Extend selection to end *after* current end */ /* Extend selection to end *after* current end */
new_start = *start; new_start = *start;
new_end = (struct coord){col, row}; new_end = (struct coord){col, row};
direction = SELECTION_RIGHT;
} }
else { else {
@ -499,15 +502,18 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
/* Move start point */ /* Move start point */
new_start = *end; new_start = *end;
new_end = (struct coord){col, row}; new_end = (struct coord){col, row};
direction = SELECTION_LEFT;
} }
else { else {
/* Move end point */ /* Move end point */
new_start = *start; new_start = *start;
new_end = (struct coord){col, row}; new_end = (struct coord){col, row};
direction = SELECTION_RIGHT;
} }
} }
term->selection.direction = direction;
selection_modify(term, new_start, new_end); selection_modify(term, new_start, new_end);
} }