diff --git a/src/main/kotlin/app/git/LogManager.kt b/src/main/kotlin/app/git/LogManager.kt index a6be07d..73c6f4c 100644 --- a/src/main/kotlin/app/git/LogManager.kt +++ b/src/main/kotlin/app/git/LogManager.kt @@ -43,6 +43,8 @@ class LogManager @Inject constructor() { } + commitList.calcMaxLine() + return@withContext commitList } diff --git a/src/main/kotlin/app/git/graph/GraphCommitList.kt b/src/main/kotlin/app/git/graph/GraphCommitList.kt index 2da2f78..f29b89e 100644 --- a/src/main/kotlin/app/git/graph/GraphCommitList.kt +++ b/src/main/kotlin/app/git/graph/GraphCommitList.kt @@ -26,6 +26,9 @@ class GraphCommitList : RevCommitList() { private val freePositions = TreeSet() private val activeLanes = HashSet(32) + var maxLine = 0 + private set + /** number of (child) commits on a lane */ private val laneLength = HashMap( 32 @@ -346,4 +349,8 @@ class GraphCommitList : RevCommitList() { for (l in graphNode.mergingLanes) blockedPositions.set(l.position) } } + + fun calcMaxLine() { + maxLine = this.maxOf { it.lane.position } + } } \ No newline at end of file diff --git a/src/main/kotlin/app/ui/log/Log.kt b/src/main/kotlin/app/ui/log/Log.kt index cc0395e..b905bf7 100644 --- a/src/main/kotlin/app/ui/log/Log.kt +++ b/src/main/kotlin/app/ui/log/Log.kt @@ -241,7 +241,7 @@ fun SearchFilter( .focusRequester(textFieldFocusRequester) .onPreviewKeyEvent { when { - it.key == Key.Enter && it.type == KeyEventType.KeyUp-> { + it.key == Key.Enter && it.type == KeyEventType.KeyUp -> { scope.launch { logViewModel.selectNextFilterCommit() } @@ -334,7 +334,8 @@ fun MessagesList( }) } items(items = commitList) { graphNode -> - CommitLine(graphWidth = graphWidth, + CommitLine( + graphWidth = graphWidth, logViewModel = logViewModel, graphNode = graphNode, selected = selectedCommit?.name == graphNode.name, @@ -363,14 +364,12 @@ fun GraphList( scrollState: LazyListState, hasUncommitedChanges: Boolean, ) { - val graphRealWidth = remember(commitList, graphWidth) { - val maxLinePosition = if (commitList.isNotEmpty()) - commitList.maxOf { it.lane.position } - else - MIN_GRAPH_LANES + val maxLinePosition = if (commitList.isNotEmpty()) + commitList.maxLine + else + MIN_GRAPH_LANES - ((maxLinePosition + MARGIN_GRAPH_LANES) * LANE_WIDTH).dp - } + val graphRealWidth = ((maxLinePosition + MARGIN_GRAPH_LANES) * LANE_WIDTH).dp Box( Modifier.width(graphWidth).fillMaxHeight()