aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Toohey2022-10-29 21:23:18 +0000
committerGitHub2022-10-29 21:23:18 +0000
commit00cf12f571b72451bcdd5c2b0079ce2331a0869f (patch)
treeafcbb87ce8c2e2faf9005667e7001729a37b12b2
parentf054a3f3ed445cdfa8c0dc63698659ef30af57b7 (diff)
fix: make `scroll` aware of tabs and wide characters (#4519)
-rw-r--r--helix-term/src/commands.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 172a7b2e..adb4802d 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1360,7 +1360,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);
@@ -1392,7 +1392,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