@@ -1360,7 +1360,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
1360 let range = doc.selection(view.id).primary();
1360 let range = doc.selection(view.id).primary();
1361 let text = doc.text().slice(..);
1361 let text = doc.text().slice(..);
1363− let cursor = coords_at_pos(text, range.cursor(text));
1363+ let cursor = visual_coords_at_pos(text, range.cursor(text), doc.tab_width());
1364 let doc_last_line = doc.text().len_lines().saturating_sub(1);
1364 let doc_last_line = doc.text().len_lines().saturating_sub(1);
1366 let last_line = view.last_line(doc);
1366 let last_line = view.last_line(doc);
@@ -1392,7 +1392,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
1393 // If cursor needs moving, replace primary selection
1393 // If cursor needs moving, replace primary selection
1394 if line != cursor.row {
1394 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
1397 let anchor = if cx.editor.mode == Mode::Select {
1397 let anchor = if cx.editor.mode == Mode::Select {
1398 range.anchor
1398 range.anchor