mirror of https://github.com/helix-editor/helix
fix: copy_selection needs to account for to() being exclusive
Fixes #1367 Fixes #1590pull/1903/head
parent
4eed4c26e9
commit
ab7885e934
|
@ -1342,8 +1342,17 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
|
||||||
let mut primary_index = 0;
|
let mut primary_index = 0;
|
||||||
for range in selection.iter() {
|
for range in selection.iter() {
|
||||||
let is_primary = *range == selection.primary();
|
let is_primary = *range == selection.primary();
|
||||||
let head_pos = coords_at_pos(text, range.head);
|
|
||||||
|
// The range is always head exclusive
|
||||||
|
let head = if range.anchor < range.head {
|
||||||
|
range.head - 1
|
||||||
|
} else {
|
||||||
|
range.head
|
||||||
|
};
|
||||||
|
|
||||||
|
let head_pos = coords_at_pos(text, head);
|
||||||
let anchor_pos = coords_at_pos(text, range.anchor);
|
let anchor_pos = coords_at_pos(text, range.anchor);
|
||||||
|
|
||||||
let height = std::cmp::max(head_pos.row, anchor_pos.row)
|
let height = std::cmp::max(head_pos.row, anchor_pos.row)
|
||||||
- std::cmp::min(head_pos.row, anchor_pos.row)
|
- std::cmp::min(head_pos.row, anchor_pos.row)
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
Loading…
Reference in New Issue