diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-04-08 09:31:14 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 09:31:14 +1000 |
commit | 426375b7cdc6727a49a5caab051b82b00babbdc2 (patch) | |
tree | 5a71a868efe921c21302d854cdae2f1845c384f5 /pkg/gui/patch_exploring/focus.go | |
parent | ed61b9a7f2e2ca07643ded8e33a6d38e57f32b22 (diff) | |
parent | f933a2f7ec2e0ab280d41a7d1582729c1acab92b (diff) |
Replace min/max helpers with built-in min/max (#3482)
- **PR Description**
We upgraded our minimum Go version to 1.21 in commit
57ac9c2189458a7f0e63c2e9cac8334694a3d545. 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
- **Please check if the PR fulfills these requirements**
* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc
<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
Diffstat (limited to 'pkg/gui/patch_exploring/focus.go')
-rw-r--r-- | pkg/gui/patch_exploring/focus.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/pkg/gui/patch_exploring/focus.go b/pkg/gui/patch_exploring/focus.go index 02fed7b28..084eefcd0 100644 --- a/pkg/gui/patch_exploring/focus.go +++ b/pkg/gui/patch_exploring/focus.go @@ -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 } |