mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-10 04:07:18 +02:00
add mergeConflict#hasAncestor
This commit is contained in:
parent
73548fa15f
commit
cf8ded0b79
@ -20,7 +20,7 @@ func ColoredConflictFile(content string, state *State, hasFocus bool) string {
|
||||
textStyle = style.FgRed
|
||||
}
|
||||
|
||||
if hasFocus && state.conflictIndex < len(state.conflicts) && *state.conflicts[state.conflictIndex] == *conflict && shouldHighlightLine(i, conflict, state.conflictSelection) {
|
||||
if hasFocus && state.conflictIndex < len(state.conflicts) && *state.conflicts[state.conflictIndex] == *conflict && shouldHighlightLine(i, conflict, state.Selection()) {
|
||||
textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor).SetBold()
|
||||
}
|
||||
if i == conflict.end && len(remainingConflicts) > 0 {
|
||||
@ -38,7 +38,7 @@ func shiftConflict(conflicts []*mergeConflict) (*mergeConflict, []*mergeConflict
|
||||
func shouldHighlightLine(index int, conflict *mergeConflict, selection Selection) bool {
|
||||
switch selection {
|
||||
case TOP:
|
||||
if conflict.ancestor >= 0 {
|
||||
if conflict.hasAncestor() {
|
||||
return index >= conflict.start && index <= conflict.ancestor
|
||||
} else {
|
||||
return index >= conflict.start && index <= conflict.target
|
||||
|
@ -25,6 +25,10 @@ type mergeConflict struct {
|
||||
end int
|
||||
}
|
||||
|
||||
func (c *mergeConflict) hasAncestor() bool {
|
||||
return c.ancestor >= 0
|
||||
}
|
||||
|
||||
type State struct {
|
||||
sync.Mutex
|
||||
conflictIndex int
|
||||
@ -48,7 +52,7 @@ func (s *State) SelectPrevConflictHunk() {
|
||||
case MIDDLE:
|
||||
s.conflictSelection = TOP
|
||||
case BOTTOM:
|
||||
if s.currentConflict().ancestor >= 0 {
|
||||
if s.currentConflict().hasAncestor() {
|
||||
s.conflictSelection = MIDDLE
|
||||
} else {
|
||||
s.conflictSelection = TOP
|
||||
@ -59,7 +63,7 @@ func (s *State) SelectPrevConflictHunk() {
|
||||
func (s *State) SelectNextConflictHunk() {
|
||||
switch s.conflictSelection {
|
||||
case TOP:
|
||||
if s.currentConflict().ancestor >= 0 {
|
||||
if s.currentConflict().hasAncestor() {
|
||||
s.conflictSelection = MIDDLE
|
||||
} else {
|
||||
s.conflictSelection = BOTTOM
|
||||
@ -163,7 +167,7 @@ func isIndexToDelete(i int, conflict *mergeConflict, selection Selection) bool {
|
||||
var isWantedContent bool
|
||||
switch selection {
|
||||
case TOP:
|
||||
if conflict.ancestor >= 0 {
|
||||
if conflict.hasAncestor() {
|
||||
isWantedContent = conflict.start < i && i < conflict.ancestor
|
||||
} else {
|
||||
isWantedContent = conflict.start < i && i < conflict.target
|
||||
|
Loading…
Reference in New Issue
Block a user