Fix overflow
This commit is contained in:
parent
28d9673a8e
commit
2d629a880c
1 changed files with 3 additions and 3 deletions
|
@ -129,7 +129,7 @@ impl EditorView {
|
||||||
})],
|
})],
|
||||||
};
|
};
|
||||||
let mut spans = Vec::new();
|
let mut spans = Vec::new();
|
||||||
let mut visual_x = 0;
|
let mut visual_x = 0u16;
|
||||||
let mut line = 0u16;
|
let mut line = 0u16;
|
||||||
let tab_width = doc.tab_width();
|
let tab_width = doc.tab_width();
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ impl EditorView {
|
||||||
break 'outer;
|
break 'outer;
|
||||||
}
|
}
|
||||||
} else if grapheme == "\t" {
|
} else if grapheme == "\t" {
|
||||||
visual_x += (tab_width as u16);
|
visual_x = visual_x.saturating_add(tab_width as u16);
|
||||||
} else {
|
} else {
|
||||||
let out_of_bounds = visual_x < view.first_col as u16
|
let out_of_bounds = visual_x < view.first_col as u16
|
||||||
|| visual_x >= viewport.width + 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 out_of_bounds {
|
||||||
// if we're offscreen just keep going until we hit a new line
|
// if we're offscreen just keep going until we hit a new line
|
||||||
visual_x += width;
|
visual_x = visual_x.saturating_add(width);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue