on master help sign in
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.

commit2a853cd41dd15d2891ac6ca17372c9f5f00a8528 authorIvan Tham <pickfire@riseup.net> dateWed 20 Apr 2022, 09:46 (5 years ago) parent5d5b6ba
1 file changed+4−2
helix-term/src/commands.rs+4−2
helix-term/src/commands.rs+4−2
@@ -2292,8 +2292,10 @@ fn open(cx: &mut Context, open: Open) {
22922292 let mut offs = 0;
22932293
22942294 let mut transaction = Transaction::change_by_selection(contents, selection, |range| {
2295− let cursor_line = range.cursor_line(text);
2296−
2295+ let cursor_line = text.char_to_line(match open {
2296+ Open::Below => graphemes::prev_grapheme_boundary(text, range.to()),
2297+ Open::Above => range.from(),
2298+ });
22972299 let new_line = match open {
22982300 // adjust position to the end of the line (next line - 1)
22992301 Open::Below => cursor_line + 1,