Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/commands/git_commands/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestCommitShowCmdObj(t *testing.T) {
type scenario struct {
testName string
filterPath string
contextSize int
contextSize uint64
similarityThreshold int
ignoreWhitespace bool
extDiffCmd string
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/git_commands/stash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
type scenario struct {
testName string
index int
contextSize int
contextSize uint64
similarityThreshold int
ignoreWhitespace bool
expected []string
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/git_commands/working_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestWorkingTreeDiff(t *testing.T) {
plain bool
cached bool
ignoreWhitespace bool
contextSize int
contextSize uint64
similarityThreshold int
runner *oscommands.FakeCmdObjRunner
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
reverse bool
plain bool
ignoreWhitespace bool
contextSize int
contextSize uint64
runner *oscommands.FakeCmdObjRunner
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ type AppState struct {

HideCommandLog bool
IgnoreWhitespaceInDiffView bool
DiffContextSize int
DiffContextSize uint64
RenameSimilarityThreshold int
LocalBranchSortOrder string
RemoteBranchSortOrder string
Expand Down
13 changes: 8 additions & 5 deletions pkg/gui/controllers/context_lines_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import (
"errors"
"fmt"
"math"

"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
Expand Down Expand Up @@ -68,22 +69,24 @@ func (self *ContextLinesController) Increase() error {
return err
}

self.c.AppState.DiffContextSize++
if self.c.AppState.DiffContextSize < math.MaxUint64 {
self.c.AppState.DiffContextSize++
}
return self.applyChange()
}

return nil
}

func (self *ContextLinesController) Decrease() error {
old_size := self.c.AppState.DiffContextSize

if self.isShowingDiff() && old_size > 1 {
if self.isShowingDiff() {
if err := self.checkCanChangeContext(); err != nil {
return err
}

self.c.AppState.DiffContextSize = old_size - 1
if self.c.AppState.DiffContextSize > 0 {
self.c.AppState.DiffContextSize--
}
return self.applyChange()
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/integration/tests/staging/diff_context_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{
Contains(`+3b`),
Contains(` 4a`),
).
Press(keys.Universal.DecreaseContextInDiffView).
Tap(func() {
t.ExpectToast(Equals("Changed diff context size to 0"))
}).
SelectedLines(
Contains(`@@ -3,1 +3 @@`),
Contains(`-3a`),
Contains(`+3b`),
).
Press(keys.Universal.IncreaseContextInDiffView).
Tap(func() {
t.ExpectToast(Equals("Changed diff context size to 1"))
}).
SelectedLines(
Contains(`@@ -2,3 +2,3 @@`),
Contains(` 2a`),
Contains(`-3a`),
Contains(`+3b`),
Contains(` 4a`),
).
Press(keys.Universal.IncreaseContextInDiffView).
Tap(func() {
t.ExpectToast(Equals("Changed diff context size to 2"))
Expand Down
Loading