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