aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-11-04 18:01:59 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-11-06 19:09:26 +0000
commit66f846d72324ecb030236e3dd0b7001c0840a7a5 (patch)
tree4358e8bd9a6813957a6cb2ec57abcd1864975b25
parentinput: don’t use seat->kbd_focus as terminal when processing a key press (diff)
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
-rw-r--r--CHANGELOG.md2
-rw-r--r--selection.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc372e5e..d1e6c992 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,8 @@
argument in `ioctl(3)` is an `int` (for example: linux/ppc64).
* Crash when using the mouse in alternate scroll mode in an unfocused
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
diff --git a/selection.c b/selection.c
index 7c814467..17d47cfe 100644
--- a/selection.c
+++ b/selection.c
@@ -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);
struct coord new_start, new_end;
+ enum selection_scroll_direction direction;
if (row < start->row || (row == start->row && col < start->col)) {
/* Extend selection to start *before* current start */
new_start = *end;
new_end = (struct coord){col, row};
+ direction = SELECTION_LEFT;
}
else if (row > end->row || (row == end->row && col > end->col)) {
/* Extend selection to end *after* current end */
new_start = *start;
new_end = (struct coord){col, row};
+ direction = SELECTION_RIGHT;
}
else {
@@ -499,15 +502,18 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
/* Move start point */
new_start = *end;
new_end = (struct coord){col, row};
+ direction = SELECTION_LEFT;
}
else {
/* Move end point */
new_start = *start;
new_end = (struct coord){col, row};
+ direction = SELECTION_RIGHT;
}
}
+ term->selection.direction = direction;
selection_modify(term, new_start, new_end);
}