1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

use an unsigned_64 for DiffContextSize and add saturated add/subtract

This commit is contained in:
LU Jialin
2024-11-07 23:09:32 -08:00
committed by Jesse Duffield
parent 9f03f9e95d
commit 111407d9a6
2 changed files with 9 additions and 6 deletions

View File

@ -457,7 +457,7 @@ type AppState struct {
HideCommandLog bool HideCommandLog bool
IgnoreWhitespaceInDiffView bool IgnoreWhitespaceInDiffView bool
DiffContextSize int DiffContextSize uint64
RenameSimilarityThreshold int RenameSimilarityThreshold int
LocalBranchSortOrder string LocalBranchSortOrder string
RemoteBranchSortOrder string RemoteBranchSortOrder string

View File

@ -3,6 +3,7 @@ package controllers
import ( import (
"errors" "errors"
"fmt" "fmt"
"math"
"github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
@ -68,7 +69,9 @@ func (self *ContextLinesController) Increase() error {
return err return err
} }
self.c.AppState.DiffContextSize++ if self.c.AppState.DiffContextSize < math.MaxUint64 {
self.c.AppState.DiffContextSize++
}
return self.applyChange() return self.applyChange()
} }
@ -76,14 +79,14 @@ func (self *ContextLinesController) Increase() error {
} }
func (self *ContextLinesController) Decrease() error { func (self *ContextLinesController) Decrease() error {
old_size := self.c.AppState.DiffContextSize if self.isShowingDiff() {
if self.isShowingDiff() && old_size > 1 {
if err := self.checkCanChangeContext(); err != nil { if err := self.checkCanChangeContext(); err != nil {
return err return err
} }
self.c.AppState.DiffContextSize = old_size - 1 if self.c.AppState.DiffContextSize > 0 {
self.c.AppState.DiffContextSize--
}
return self.applyChange() return self.applyChange()
} }