mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-24 17:45:00 +03:00
try to keep selection
This commit is contained in:
parent
b380d0964a
commit
0234b9f87b
@ -38,8 +38,12 @@ impl IndexComponent {
|
||||
if hash(&self.items) != hash(list) {
|
||||
self.items = list.clone();
|
||||
|
||||
self.selection =
|
||||
if self.items.len() > 0 { Some(0) } else { None };
|
||||
let old_selection = self.selection.unwrap_or_default();
|
||||
self.selection = if self.items.len() > 0 {
|
||||
Some(cmp::min(old_selection, self.items.len() - 1))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user