mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Replace min/max helpers with built-in min/max
We upgraded our minimum Go version to 1.21 in commit
57ac9c2189
. We can now replace our
`utils.Min` and `utils.Max` functions with the built-in `min` and `max`.
Reference: https://go.dev/ref/spec#Min_and_max
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
package patch_exploring
|
||||
|
||||
import "github.com/jesseduffield/lazygit/pkg/utils"
|
||||
|
||||
func calculateOrigin(currentOrigin int, bufferHeight int, numLines int, firstLineIdx int, lastLineIdx int, selectedLineIdx int, mode selectMode) int {
|
||||
needToSeeIdx, wantToSeeIdx := getNeedAndWantLineIdx(firstLineIdx, lastLineIdx, selectedLineIdx, mode)
|
||||
|
||||
@ -14,7 +12,7 @@ func calculateOrigin(currentOrigin int, bufferHeight int, numLines int, firstLin
|
||||
func calculateNewOriginWithNeededAndWantedIdx(currentOrigin int, bufferHeight int, numLines int, needToSeeIdx int, wantToSeeIdx int) int {
|
||||
origin := currentOrigin
|
||||
if needToSeeIdx < currentOrigin || needToSeeIdx > currentOrigin+bufferHeight {
|
||||
origin = utils.Max(utils.Min(needToSeeIdx-bufferHeight/2, numLines-bufferHeight-1), 0)
|
||||
origin = max(min(needToSeeIdx-bufferHeight/2, numLines-bufferHeight-1), 0)
|
||||
}
|
||||
|
||||
bottom := origin + bufferHeight
|
||||
@ -22,11 +20,11 @@ func calculateNewOriginWithNeededAndWantedIdx(currentOrigin int, bufferHeight in
|
||||
if wantToSeeIdx < origin {
|
||||
requiredChange := origin - wantToSeeIdx
|
||||
allowedChange := bottom - needToSeeIdx
|
||||
return origin - utils.Min(requiredChange, allowedChange)
|
||||
return origin - min(requiredChange, allowedChange)
|
||||
} else if wantToSeeIdx > origin+bufferHeight {
|
||||
requiredChange := wantToSeeIdx - bottom
|
||||
allowedChange := needToSeeIdx - origin
|
||||
return origin + utils.Min(requiredChange, allowedChange)
|
||||
return origin + min(requiredChange, allowedChange)
|
||||
} else {
|
||||
return origin
|
||||
}
|
||||
|
Reference in New Issue
Block a user