From e2951b66fafadc47a0c7148404a5eb8a5cc77655 Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Mon, 23 Feb 2026 11:46:04 +0300 Subject: [PATCH] fix(git-panel): improve commit expansion logic and fetch diff condition --- .../git-panel/view/history/HistoryView.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/git-panel/view/history/HistoryView.tsx b/src/components/git-panel/view/history/HistoryView.tsx index 62ffaa6..0ffbdf6 100644 --- a/src/components/git-panel/view/history/HistoryView.tsx +++ b/src/components/git-panel/view/history/HistoryView.tsx @@ -24,21 +24,24 @@ export default function HistoryView({ const toggleCommitExpanded = useCallback( (commitHash: string) => { + const isExpanding = !expandedCommits.has(commitHash); + setExpandedCommits((previous) => { const next = new Set(previous); if (next.has(commitHash)) { next.delete(commitHash); } else { next.add(commitHash); - // Load commit diff lazily only the first time a commit is expanded. - if (!commitDiffs[commitHash]) { - void onFetchCommitDiff(commitHash); - } } return next; }); + + // Load commit diff lazily only the first time a commit is expanded. + if (isExpanding && !commitDiffs[commitHash]) { + void onFetchCommitDiff(commitHash); + } }, - [commitDiffs, onFetchCommitDiff], + [commitDiffs, expandedCommits, onFetchCommitDiff, setExpandedCommits], ); return (