We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
+
1 parent 668bf38 commit 50e4992Copy full SHA for 50e4992
helix-core/src/position.rs
@@ -262,7 +262,14 @@ pub fn visual_offset_from_anchor(
262
pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
263
let Position { mut row, col } = coords;
264
if limit_before_line_ending {
265
- row = row.min(text.len_lines() - 1);
+ 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
+ });
273
};
274
let line_start = text.line_to_char(row);
275
let line_end = if limit_before_line_ending {
0 commit comments