Skip to content

Commit ac6c024

Browse files
committed
Reduce redundant highlighting-code by modifying if-conditions
1 parent c9fe20a commit ac6c024

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

src/Models/CommitGraph.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,31 +146,23 @@ public static CommitGraph Generate(List<Commit> commits, bool firstParentOnlyEna
146146
{
147147
isHighlighted = true;
148148
}
149-
else if (highlighting == CommitGraphHighlighting.CurrentBranchOnly)
149+
150+
if (!isHighlighted &&
151+
(highlighting == CommitGraphHighlighting.CurrentBranchOnly ||
152+
highlighting == CommitGraphHighlighting.CurrentBranchAndSelectedCommits))
150153
{
151154
isHighlighted = commit.IsMerged;
152155
}
153-
else if (highlighting == CommitGraphHighlighting.SelectedCommitsOnly)
156+
157+
if (!isHighlighted &&
158+
(highlighting == CommitGraphHighlighting.SelectedCommitsOnly ||
159+
highlighting == CommitGraphHighlighting.CurrentBranchAndSelectedCommits))
154160
{
155161
isHighlighted = highlightExtraCommits.Remove(commit.SHA);
156162
// Highlight first parent, other parents are dealt with later
157163
if (isHighlighted && commit.Parents.Count > 0)
158164
highlightExtraCommits.Add(commit.Parents[0]);
159165
}
160-
else
161-
{
162-
if (commit.IsMerged)
163-
{
164-
isHighlighted = true;
165-
}
166-
else
167-
{
168-
isHighlighted = highlightExtraCommits.Remove(commit.SHA);
169-
// Highlight first parent, other parents are dealt with later
170-
if (isHighlighted && commit.Parents.Count > 0)
171-
highlightExtraCommits.Add(commit.Parents[0]);
172-
}
173-
}
174166
}
175167
commit.IsHighlightedInGraph = isHighlighted;
176168

0 commit comments

Comments
 (0)