aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorA-Walrus2022-07-04 22:51:15 +0000
committerGitHub2022-07-04 22:51:15 +0000
commit2ac1de305e10238a2e7ed8c0d66f3fa78566dbaa (patch)
treed4733755fcabb60db3ade2b222b6c12134306037 /helix-term/src
parent244825b9e1959939e1c08fe942a288d10eb6da69 (diff)
Fix backwards selection duplication widening bug (#2945)
* Fix backwards selection duplication widening bug * Add integration tests * Make tests line-ending agnostic Make tests line-ending agnostic Use indoc to fix tests Fix line-ending on test input
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index df4867fc..c9e35062 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1411,16 +1411,16 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
let is_primary = *range == selection.primary();
// The range is always head exclusive
- let head = if range.anchor < range.head {
- range.head - 1
+ let (head, anchor) = if range.anchor < range.head {
+ (range.head - 1, range.anchor)
} else {
- range.head
+ (range.head, range.anchor - 1)
};
let tab_width = doc.tab_width();
let head_pos = visual_coords_at_pos(text, head, tab_width);
- let anchor_pos = visual_coords_at_pos(text, range.anchor, tab_width);
+ let anchor_pos = visual_coords_at_pos(text, anchor, tab_width);
let height = std::cmp::max(head_pos.row, anchor_pos.row)
- std::cmp::min(head_pos.row, anchor_pos.row)