Skip to content

Commit 954347c

Browse files
authored
Use custom context size in range diff (#4082)
- **PR Description** I just noticed that we don't respect the diff context size when showing a range diff (both the "sticky" range diff when diffing mode is on, and the more temporary one when selecting a range of commits). Here's a quick fix for that. I was too lazy to add tests for this, let me know if you would find this important. Right now, it seems we only have tests for the context size in the staging view, not in any of the other places where diffs can be shown. - **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)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [ ] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc
2 parents 53dc23a + 7fb9e8f commit 954347c

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

pkg/commands/git_commands/diff.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func NewDiffCommands(gitCommon *GitCommon) *DiffCommands {
1919
func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj {
2020
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
2121
useExtDiff := extDiffCmd != ""
22+
ignoreWhitespace := self.AppState.IgnoreWhitespaceInDiffView
2223

2324
return self.cmd.New(
2425
NewGitCmd("diff").
@@ -27,6 +28,8 @@ func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj {
2728
ArgIfElse(useExtDiff, "--ext-diff", "--no-ext-diff").
2829
Arg("--submodule").
2930
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
31+
ArgIf(ignoreWhitespace, "--ignore-all-space").
32+
Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)).
3033
Arg(diffArgs...).
3134
Dir(self.repoPaths.worktreePath).
3235
ToArgv(),

pkg/gui/controllers/helpers/diff_helper.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ func (self *DiffHelper) DiffArgs() []string {
3434
output = append(output, "-R")
3535
}
3636

37-
if self.c.GetAppState().IgnoreWhitespaceInDiffView {
38-
output = append(output, "--ignore-all-space")
39-
}
40-
4137
output = append(output, "--")
4238

4339
file := self.currentlySelectedFilename()
@@ -59,9 +55,6 @@ func (self *DiffHelper) GetUpdateTaskForRenderingCommitsDiff(commit *models.Comm
5955
if refRange != nil {
6056
from, to := refRange.From, refRange.To
6157
args := []string{from.ParentRefName(), to.RefName(), "--stat", "-p"}
62-
if self.c.GetAppState().IgnoreWhitespaceInDiffView {
63-
args = append(args, "--ignore-all-space")
64-
}
6558
args = append(args, "--")
6659
if path := self.c.Modes().Filtering.GetPath(); path != "" {
6760
args = append(args, path)

0 commit comments

Comments
 (0)