Skip to content

Commit

Permalink
Fix open on multiline selection (#2161)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pickfire committed Apr 20, 2022
1 parent 5d5b6ba commit 2a853cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2a853cd

Please sign in to comment.