diff options
author | Davyd McColl <davydm@gmail.com> | 2021-05-28 12:02:19 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-07-01 17:13:13 +1000 |
commit | a9f04d3925bff4ec487a8c622ce84c79ef64ab87 (patch) | |
tree | 58f80bb76136d06e5c5d189f89fd4174c3099d58 /pkg/commands/files.go | |
parent | 83834a2c2e50922d58b052b116d50a9fc3903e84 (diff) |
:sparkles: facilitate toggling whitespace in the diff view with a hotkey (c-w by default)
Diffstat (limited to 'pkg/commands/files.go')
-rw-r--r-- | pkg/commands/files.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 9e077a462..648c5f511 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -189,17 +189,18 @@ func (c *GitCommand) Ignore(filename string) error { } // WorktreeFileDiff returns the diff of a file -func (c *GitCommand) WorktreeFileDiff(file *models.File, plain bool, cached bool) string { +func (c *GitCommand) WorktreeFileDiff(file *models.File, plain bool, cached bool, ignoreWhitespace bool) string { // for now we assume an error means the file was deleted - s, _ := c.OSCommand.RunCommandWithOutput(c.WorktreeFileDiffCmdStr(file, plain, cached)) + s, _ := c.OSCommand.RunCommandWithOutput(c.WorktreeFileDiffCmdStr(file, plain, cached, ignoreWhitespace)) return s } -func (c *GitCommand) WorktreeFileDiffCmdStr(node models.IFile, plain bool, cached bool) string { +func (c *GitCommand) WorktreeFileDiffCmdStr(node models.IFile, plain bool, cached bool, ignoreWhitespace bool) string { cachedArg := "" trackedArg := "--" colorArg := c.colorArg() path := c.OSCommand.Quote(node.GetPath()) + ignoreWhitespaceArg := "" if cached { cachedArg = "--cached" } @@ -209,8 +210,11 @@ func (c *GitCommand) WorktreeFileDiffCmdStr(node models.IFile, plain bool, cache if plain { colorArg = "never" } + if ignoreWhitespace { + ignoreWhitespaceArg = "-w" + } - return fmt.Sprintf("git diff --submodule --no-ext-diff --color=%s %s %s %s", colorArg, cachedArg, trackedArg, path) + return fmt.Sprintf("git diff --submodule --no-ext-diff --color=%s %s %s %s %s", colorArg, ignoreWhitespaceArg, cachedArg, trackedArg, path) } func (c *GitCommand) ApplyPatch(patch string, flags ...string) error { |