diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-14 00:18:05 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-19 10:47:21 +1100 |
commit | f3eb180f75496637719895902abf76af10b8425f (patch) | |
tree | 2734dec7d15d35e8c4ff1b65aa3d722cdbd69ac5 /pkg/gui/mergeconflicts | |
parent | c0c3aac02e048903764e4b42b513334e58855d73 (diff) |
Standardise display of range selection across views
We're not fully standardising here: different contexts can store their range state however
they like. What we are standardising on is that now the view is always responsible for
highlighting the selected lines, meaning the context/controller needs to tell the view
where the range start is.
Two convenient benefits from this change:
1) we no longer need bespoke code in integration tests for asserting on selected lines because
we can just ask the view
2) line selection in staging/patch-building/merge-conflicts views now look the same as in
list views i.e. the highlight applies to the whole line (including trailing space)
I also noticed a bug with merge conflicts not rendering the selection on focus though I suspect
it wasn't a bug with any real consequences when the view wasn't displaying the selection.
I'm going to scrap the selectedRangeBgColor config and just let it use the single line
background color. Hopefully nobody cares, but there's really no need for an extra config.
Diffstat (limited to 'pkg/gui/mergeconflicts')
-rw-r--r-- | pkg/gui/mergeconflicts/rendering.go | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/pkg/gui/mergeconflicts/rendering.go b/pkg/gui/mergeconflicts/rendering.go index 54fc4e836..e57754e4b 100644 --- a/pkg/gui/mergeconflicts/rendering.go +++ b/pkg/gui/mergeconflicts/rendering.go @@ -8,7 +8,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -func ColoredConflictFile(state *State, hasFocus bool) string { +func ColoredConflictFile(state *State) string { content := state.GetContent() if len(state.conflicts) == 0 { return content @@ -21,9 +21,6 @@ func ColoredConflictFile(state *State, hasFocus bool) string { textStyle = style.FgRed } - 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 { conflict, remainingConflicts = shiftConflict(remainingConflicts) } @@ -35,8 +32,3 @@ func ColoredConflictFile(state *State, hasFocus bool) string { func shiftConflict(conflicts []*mergeConflict) (*mergeConflict, []*mergeConflict) { return conflicts[0], conflicts[1:] } - -func shouldHighlightLine(index int, conflict *mergeConflict, selection Selection) bool { - selectionStart, selectionEnd := selection.bounds(conflict) - return index >= selectionStart && index <= selectionEnd -} |