on master help sign in
fix: copy_selection needs to account for to() being exclusive
ab7885eBlaž Hrastnik
helix-term/src/commands.rs+10−1
@@ -1342,8 +1342,17 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
1342 let mut primary_index = 0;
1342 let mut primary_index = 0;
1343 for range in selection.iter() {
1343 for range in selection.iter() {
1344 let is_primary = *range == selection.primary();
1344 let is_primary = *range == selection.primary();
1345+
1346+ // The range is always head exclusive
1347+ let head = if range.anchor < range.head {
1348+ range.head - 1
1349+ } else {
1350+ range.head
1351+ };
1352+
1345− let head_pos = coords_at_pos(text, range.head);
1353+ let head_pos = coords_at_pos(text, head);
1346 let anchor_pos = coords_at_pos(text, range.anchor);
1354 let anchor_pos = coords_at_pos(text, range.anchor);
1355+
1347 let height = std::cmp::max(head_pos.row, anchor_pos.row)
1356 let height = std::cmp::max(head_pos.row, anchor_pos.row)
1348 - std::cmp::min(head_pos.row, anchor_pos.row)
1357 - std::cmp::min(head_pos.row, anchor_pos.row)
1349 + 1;
1358 + 1;