mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
better rendering of bisect markets in commits panel
This commit is contained in:
parent
ca7cfc3232
commit
5e9cfab283
@ -77,7 +77,7 @@ func (self *ListContext) FocusLine() {
|
||||
view.FocusPoint(view.OriginX(), self.GetPanelState().GetSelectedLineIdx())
|
||||
if self.RenderSelection {
|
||||
_, originY := view.Origin()
|
||||
displayStrings := self.GetDisplayStrings(originY, view.InnerHeight())
|
||||
displayStrings := self.GetDisplayStrings(originY, view.InnerHeight()+1)
|
||||
self.Gui.renderDisplayStringsAtPos(view, originY, displayStrings)
|
||||
}
|
||||
view.Footer = formatListFooter(self.GetPanelState().GetSelectedLineIdx(), self.GetItemsLength())
|
||||
|
@ -22,13 +22,10 @@ type pipeSetCacheKey struct {
|
||||
var pipeSetCache = make(map[pipeSetCacheKey][][]*graph.Pipe)
|
||||
var mutex sync.Mutex
|
||||
|
||||
type BisectProgress int
|
||||
|
||||
const (
|
||||
BeforeNewCommit BisectProgress = iota
|
||||
InbetweenCommits
|
||||
AfterOldCommit
|
||||
)
|
||||
type bisectBounds struct {
|
||||
newIndex int
|
||||
oldIndex int
|
||||
}
|
||||
|
||||
func GetCommitListDisplayStrings(
|
||||
commits []*models.Commit,
|
||||
@ -60,6 +57,8 @@ func GetCommitListDisplayStrings(
|
||||
|
||||
filteredCommits := commits[startIdx:end]
|
||||
|
||||
bisectBounds := getbisectBounds(commits, bisectInfo)
|
||||
|
||||
// function expects to be passed the index of the commit in terms of the `commits` slice
|
||||
var getGraphLine func(int) string
|
||||
if showGraph {
|
||||
@ -88,16 +87,16 @@ func GetCommitListDisplayStrings(
|
||||
}
|
||||
|
||||
lines := make([][]string, 0, len(filteredCommits))
|
||||
bisectProgress := BeforeNewCommit
|
||||
var bisectStatus BisectStatus
|
||||
for i, commit := range filteredCommits {
|
||||
bisectStatus, bisectProgress = getBisectStatus(commit.Sha, bisectInfo, bisectProgress)
|
||||
unfilteredIdx := i + startIdx
|
||||
bisectStatus = getBisectStatus(unfilteredIdx, commit.Sha, bisectInfo, bisectBounds)
|
||||
lines = append(lines, displayCommit(
|
||||
commit,
|
||||
cherryPickedCommitShaMap,
|
||||
diffName,
|
||||
parseEmoji,
|
||||
getGraphLine(i+startIdx),
|
||||
getGraphLine(unfilteredIdx),
|
||||
fullDescription,
|
||||
bisectStatus,
|
||||
bisectInfo,
|
||||
@ -106,6 +105,29 @@ func GetCommitListDisplayStrings(
|
||||
return lines
|
||||
}
|
||||
|
||||
func getbisectBounds(commits []*models.Commit, bisectInfo *git_commands.BisectInfo) *bisectBounds {
|
||||
if !bisectInfo.Bisecting() {
|
||||
return nil
|
||||
}
|
||||
|
||||
bisectBounds := &bisectBounds{}
|
||||
|
||||
for i, commit := range commits {
|
||||
if commit.Sha == bisectInfo.GetNewSha() {
|
||||
bisectBounds.newIndex = i
|
||||
}
|
||||
|
||||
status, ok := bisectInfo.Status(commit.Sha)
|
||||
if ok && status == git_commands.BisectStatusOld {
|
||||
bisectBounds.oldIndex = i
|
||||
return bisectBounds
|
||||
}
|
||||
}
|
||||
|
||||
// shouldn't land here
|
||||
return nil
|
||||
}
|
||||
|
||||
// precondition: slice is not empty
|
||||
func indexOfFirstNonTODOCommit(commits []*models.Commit) int {
|
||||
for i, commit := range commits {
|
||||
@ -155,35 +177,35 @@ const (
|
||||
BisectStatusCurrent
|
||||
)
|
||||
|
||||
func getBisectStatus(commitSha string, bisectInfo *git_commands.BisectInfo, bisectProgress BisectProgress) (BisectStatus, BisectProgress) {
|
||||
func getBisectStatus(index int, commitSha string, bisectInfo *git_commands.BisectInfo, bisectBounds *bisectBounds) BisectStatus {
|
||||
if !bisectInfo.Started() {
|
||||
return BisectStatusNone, bisectProgress
|
||||
return BisectStatusNone
|
||||
}
|
||||
|
||||
if bisectInfo.GetCurrentSha() == commitSha {
|
||||
return BisectStatusCurrent, bisectProgress
|
||||
return BisectStatusCurrent
|
||||
}
|
||||
|
||||
status, ok := bisectInfo.Status(commitSha)
|
||||
if ok {
|
||||
switch status {
|
||||
case git_commands.BisectStatusNew:
|
||||
return BisectStatusNew, InbetweenCommits
|
||||
return BisectStatusNew
|
||||
case git_commands.BisectStatusOld:
|
||||
return BisectStatusOld, AfterOldCommit
|
||||
return BisectStatusOld
|
||||
case git_commands.BisectStatusSkipped:
|
||||
return BisectStatusSkipped, bisectProgress
|
||||
return BisectStatusSkipped
|
||||
}
|
||||
} else {
|
||||
if bisectProgress == InbetweenCommits && bisectInfo.Bisecting() {
|
||||
return BisectStatusCandidate, bisectProgress
|
||||
if bisectBounds != nil && index >= bisectBounds.newIndex && index <= bisectBounds.oldIndex {
|
||||
return BisectStatusCandidate
|
||||
} else {
|
||||
return BisectStatusNone, bisectProgress
|
||||
return BisectStatusNone
|
||||
}
|
||||
}
|
||||
|
||||
// should never land here
|
||||
return BisectStatusNone, bisectProgress
|
||||
return BisectStatusNone
|
||||
}
|
||||
|
||||
func getBisectStatusText(bisectStatus BisectStatus, bisectInfo *git_commands.BisectInfo) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user