Re-add assertions and simplify wrapping
This commit is contained in:
parent
3060032a95
commit
f174f364a4
1 changed files with 3 additions and 6 deletions
|
|
@ -386,6 +386,7 @@ impl UI {
|
||||||
| KeyEvent { code: KeyCode::Char('k'), .. } => {
|
| KeyEvent { code: KeyCode::Char('k'), .. } => {
|
||||||
let index = match self.selection.selected() {
|
let index = match self.selection.selected() {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
|
assert!(self.ports.len() > 0, "We must have ports because we have a selection.");
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
self.ports.len() - 1
|
self.ports.len() - 1
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -400,12 +401,8 @@ impl UI {
|
||||||
| KeyEvent { code: KeyCode::Char('j'), .. } => {
|
| KeyEvent { code: KeyCode::Char('j'), .. } => {
|
||||||
let index = match self.selection.selected() {
|
let index = match self.selection.selected() {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
let max = self.ports.len() - 1;
|
assert!(self.ports.len() > 0, "We must have ports because we have a selection.");
|
||||||
if i >= max {
|
(i + 1) % self.ports.len()
|
||||||
0
|
|
||||||
} else {
|
|
||||||
i + 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => 0,
|
None => 0,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue