Skip to content

Commit 50e4992

Browse files
authored
don't set the row position to the empty last line with the + cli arg (#14590)
1 parent 668bf38 commit 50e4992

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

helix-core/src/position.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,14 @@ pub fn visual_offset_from_anchor(
262262
pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
263263
let Position { mut row, col } = coords;
264264
if limit_before_line_ending {
265-
row = row.min(text.len_lines() - 1);
265+
let lines = text.len_lines() - 1;
266+
267+
row = row.min(if crate::line_ending::get_line_ending(&text).is_some() {
268+
// if the last line is empty, don't jump to it
269+
lines - 1
270+
} else {
271+
lines
272+
});
266273
};
267274
let line_start = text.line_to_char(row);
268275
let line_end = if limit_before_line_ending {

0 commit comments

Comments
 (0)