aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorwojciechkepka2021-06-19 19:33:20 +0000
committerBenoƮt Cortier2021-06-19 20:49:20 +0000
commit2d629a880cddec4938750b13bcd9926631c1db94 (patch)
treee89395e1bdf5d3da211e784e775f4631d45b99d7 /helix-term/src/ui
parent28d9673a8ef46a544fcd6216e932be2e5453349d (diff)
Fix overflow
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 3dc43d3f..7f0d06e9 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -129,7 +129,7 @@ impl EditorView {
})],
};
let mut spans = Vec::new();
- let mut visual_x = 0;
+ let mut visual_x = 0u16;
let mut line = 0u16;
let tab_width = doc.tab_width();
@@ -185,7 +185,7 @@ impl EditorView {
break 'outer;
}
} else if grapheme == "\t" {
- visual_x += (tab_width as u16);
+ visual_x = visual_x.saturating_add(tab_width as u16);
} else {
let out_of_bounds = visual_x < view.first_col as u16
|| visual_x >= viewport.width + view.first_col as u16;
@@ -197,7 +197,7 @@ impl EditorView {
if out_of_bounds {
// if we're offscreen just keep going until we hit a new line
- visual_x += width;
+ visual_x = visual_x.saturating_add(width);
continue;
}