ui: Wrap around list when at the endoflife
Pressing "up"/"k" at the top of the UI will now go to the end of the list. And same in reverse.
This commit is contained in:
parent
85dc2f0707
commit
3060032a95
1 changed files with 7 additions and 3 deletions
|
|
@ -387,7 +387,7 @@ impl UI {
|
||||||
let index = match self.selection.selected() {
|
let index = match self.selection.selected() {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
0
|
self.ports.len() - 1
|
||||||
} else {
|
} else {
|
||||||
i - 1
|
i - 1
|
||||||
}
|
}
|
||||||
|
|
@ -400,8 +400,12 @@ 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) => {
|
||||||
assert!(self.ports.len() > 0, "We must have ports because we have a selection.");
|
let max = self.ports.len() - 1;
|
||||||
(i + 1).min(self.ports.len() - 1)
|
if i >= max {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
i + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => 0,
|
None => 0,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue