2023-02-07 13:33:10 +01:00
|
|
|
package diff
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
2023-03-26 15:56:11 +11:00
|
|
|
var (
|
|
|
|
initialFileContent = "first-line\nold-second-line\nthird-line\n"
|
|
|
|
// We're indenting each line and modifying the second line
|
|
|
|
updatedFileContent = " first-line\n new-second-line\n third-line\n"
|
|
|
|
)
|
|
|
|
|
2023-02-07 13:33:10 +01:00
|
|
|
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{
|
2023-03-26 15:56:11 +11:00
|
|
|
Description: "Toggle whitespace in the diff",
|
2023-05-21 17:00:29 +10:00
|
|
|
ExtraCmdArgs: []string{},
|
2023-02-07 13:33:10 +01:00
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
2023-03-26 15:56:11 +11:00
|
|
|
shell.CreateFileAndAdd("myfile", initialFileContent)
|
|
|
|
shell.Commit("initial commit")
|
|
|
|
shell.UpdateFile("myfile", updatedFileContent)
|
2023-02-07 13:33:10 +01:00
|
|
|
},
|
|
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
2023-03-26 15:56:11 +11:00
|
|
|
t.Views().Main().ContainsLines(
|
|
|
|
Contains(`-first-line`),
|
|
|
|
Contains(`-old-second-line`),
|
|
|
|
Contains(`-third-line`),
|
|
|
|
Contains(`+ first-line`),
|
|
|
|
Contains(`+ new-second-line`),
|
|
|
|
Contains(`+ third-line`),
|
|
|
|
)
|
|
|
|
|
|
|
|
t.Views().Files().
|
|
|
|
IsFocused().
|
|
|
|
Press(keys.Universal.ToggleWhitespaceInDiffView)
|
|
|
|
|
|
|
|
// lines with only whitespace changes are ignored (first and third lines)
|
|
|
|
t.Views().Main().ContainsLines(
|
|
|
|
Contains(` first-line`),
|
|
|
|
Contains(`-old-second-line`),
|
|
|
|
Contains(`+ new-second-line`),
|
|
|
|
Contains(` third-line`),
|
|
|
|
)
|
|
|
|
|
|
|
|
// when toggling again it goes back to showing whitespace
|
|
|
|
t.Views().Files().
|
|
|
|
IsFocused().
|
|
|
|
Press(keys.Universal.ToggleWhitespaceInDiffView)
|
|
|
|
|
|
|
|
t.Views().Main().ContainsLines(
|
|
|
|
Contains(`-first-line`),
|
|
|
|
Contains(`-old-second-line`),
|
|
|
|
Contains(`-third-line`),
|
|
|
|
Contains(`+ first-line`),
|
|
|
|
Contains(`+ new-second-line`),
|
|
|
|
Contains(`+ third-line`),
|
|
|
|
)
|
2023-02-07 13:33:10 +01:00
|
|
|
},
|
|
|
|
})
|