Skip to content

Commit

Permalink
fix: make scroll aware of tabs and wide characters (helix-editor#4519)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoohey31 authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 8b8fbc6 commit aa1276c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
let range = doc.selection(view.id).primary();
let text = doc.text().slice(..);

let cursor = coords_at_pos(text, range.cursor(text));
let cursor = visual_coords_at_pos(text, range.cursor(text), doc.tab_width());
let doc_last_line = doc.text().len_lines().saturating_sub(1);

let last_line = view.last_line(doc);
Expand Down Expand Up @@ -1395,7 +1395,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {

// If cursor needs moving, replace primary selection
if line != cursor.row {
let head = pos_at_coords(text, Position::new(line, cursor.col), true); // this func will properly truncate to line end
let head = pos_at_visual_coords(text, Position::new(line, cursor.col), doc.tab_width()); // this func will properly truncate to line end

let anchor = if cx.editor.mode == Mode::Select {
range.anchor
Expand Down

0 comments on commit aa1276c

Please sign in to comment.