2
0
mirror of https://github.com/xvxx/phetch synced 2024-11-05 00:00:58 +00:00

dont crash on 0

This commit is contained in:
dvkt 2019-12-23 23:59:06 -08:00
parent f545bfdd03
commit 7119c5f606

View File

@ -549,7 +549,7 @@ impl Menu {
if let Some(c) = input.chars().nth(0) { if let Some(c) = input.chars().nth(0) {
if c.is_digit(10) { if c.is_digit(10) {
let i = c.to_digit(10).unwrap() as usize; let i = c.to_digit(10).unwrap() as usize;
if i <= count { if i > 0 && i <= count {
if count < (i * 10) { if count < (i * 10) {
return self.action_follow_link(i - 1); return self.action_follow_link(i - 1);
} else { } else {
@ -562,7 +562,7 @@ impl Menu {
// jump to >=10 number // jump to >=10 number
let s = input.chars().take(2).collect::<String>(); let s = input.chars().take(2).collect::<String>();
if let Ok(num) = s.parse::<usize>() { if let Ok(num) = s.parse::<usize>() {
if num <= count { if num > 0 && num <= count {
if count < (num * 10) { if count < (num * 10) {
return self.action_follow_link(num - 1); return self.action_follow_link(num - 1);
} else { } else {
@ -574,7 +574,7 @@ impl Menu {
// jump to >=100 number // jump to >=100 number
let s = input.chars().take(3).collect::<String>(); let s = input.chars().take(3).collect::<String>();
if let Ok(num) = s.parse::<usize>() { if let Ok(num) = s.parse::<usize>() {
if num <= count { if num > 0 && num <= count {
if count < (num * 10) { if count < (num * 10) {
return self.action_follow_link(num - 1); return self.action_follow_link(num - 1);
} else { } else {