Skip to content

Commit 93d30a3

Browse files
mtoohey31Frederik Vestre
authored andcommitted
fix: make scroll aware of tabs and wide characters (helix-editor#4519)
1 parent 0a2a8dc commit 93d30a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

helix-term/src/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)