aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorIvan Tham2022-04-20 01:46:46 +0000
committerGitHub2022-04-20 01:46:46 +0000
commit2a853cd41dd15d2891ac6ca17372c9f5f00a8528 (patch)
tree7f05a999cd06e3f4785b17f62594738064a0e13d /helix-term
parent5d5b6bab9ba5211c8c146fb38276f968892e7882 (diff)
Fix open on multiline selection (#2161)
Select multiple line and open should be based on the whole selection and not just the line of the cursor, which causes weird behavior like opening in the middle of the selection which user might not expect.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 15ccc247..4e13f74a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2292,8 +2292,10 @@ fn open(cx: &mut Context, open: Open) {
let mut offs = 0;
let mut transaction = Transaction::change_by_selection(contents, selection, |range| {
- let cursor_line = range.cursor_line(text);
-
+ let cursor_line = text.char_to_line(match open {
+ Open::Below => graphemes::prev_grapheme_boundary(text, range.to()),
+ Open::Above => range.from(),
+ });
let new_line = match open {
// adjust position to the end of the line (next line - 1)
Open::Below => cursor_line + 1,