From c5c3ec07f4089d831c88b3edd58bc2b6e8872a72 Mon Sep 17 00:00:00 2001 From: ahkrr Date: Sat, 5 Jun 2021 16:32:23 +0200 Subject: [PATCH] fix: panicked at 'attempt to subtract with overflow' helix-term/src/ui/editor.rs:275:29 This would happen when the window-size was to small to display the entire width and one would start jumping forwards with f and the beginning of the highlighted area would end up outside of the window --- helix-term/src/ui/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 6c39088e..2464528c 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -272,7 +272,7 @@ impl EditorView { viewport.x + start.col as u16, viewport.y + start.row as u16, // text.line(view.first_line).len_chars() as u16 - start.col as u16, - viewport.width - start.col as u16, + viewport.width.saturating_sub(start.col as u16), 1, ), selection_style,