on master help sign in
fix: make `scroll` aware of tabs and wide characters (#4519)
commit00cf12f571b72451bcdd5c2b0079ce2331a0869f authorMatthew Toohey <contact@mtoohey.com> dateSat 29 Oct 2022, 17:23 (4 years ago) parentf054a3f
1 file changed+2−2
helix-term/src/commands.rs+2−2
helix-term/src/commands.rs+2−2
@@ -1360,7 +1360,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
13601360 let range = doc.selection(view.id).primary();
13611361 let text = doc.text().slice(..);
13621362
1363− let cursor = coords_at_pos(text, range.cursor(text));
1363+ let cursor = visual_coords_at_pos(text, range.cursor(text), doc.tab_width());
13641364 let doc_last_line = doc.text().len_lines().saturating_sub(1);
13651365
13661366 let last_line = view.last_line(doc);
@@ -1392,7 +1392,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
13921392
13931393 // If cursor needs moving, replace primary selection
13941394 if line != cursor.row {
1395− let head = pos_at_coords(text, Position::new(line, cursor.col), true); // this func will properly truncate to line end
1395+ let head = pos_at_visual_coords(text, Position::new(line, cursor.col), doc.tab_width()); // this func will properly truncate to line end
13961396
13971397 let anchor = if cx.editor.mode == Mode::Select {
13981398 range.anchor