@@ -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