Fixed crash when clicking on a ref with a ref that's not shown in the log

This commit is contained in:
Abdelilah El Aissaoui 2021-12-12 20:16:00 +01:00
parent e12a5ee2e2
commit 45d89f3699

View File

@ -91,8 +91,14 @@ fun Log(
LaunchedEffect(selectedCommit) { LaunchedEffect(selectedCommit) {
// Scroll to commit if a Ref is selected // Scroll to commit if a Ref is selected
if (selectedItem is SelectedItem.Ref) if (selectedItem is SelectedItem.Ref) {
scrollState.scrollToItem(commitList.indexOfFirst { it.name == selectedCommit?.name }) val index = commitList.indexOfFirst { it.name == selectedCommit?.name }
// TODO Show a message informing the user why we aren't scrolling
// Index can be -1 if the ref points to a commit that is not shown in the graph due to the limited
// number of displayed commits.
if (index >= 0)
scrollState.scrollToItem(index)
}
} }
LogDialogs( LogDialogs(