1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-24 05:36:19 +02:00

handle diffing and filtering by file in commit files view

This commit is contained in:
Jesse Duffield 2020-08-22 16:06:09 +10:00
parent 5874529f43
commit c837c54c39

View File

@ -13,14 +13,8 @@ func (gui *Gui) exitDiffMode() error {
} }
func (gui *Gui) renderDiff() error { func (gui *Gui) renderDiff() error {
filterArg := ""
if gui.State.Modes.Filtering.Active() {
filterArg = fmt.Sprintf(" -- %s", gui.State.Modes.Filtering.Path)
}
cmd := gui.OSCommand.ExecutableFromString( cmd := gui.OSCommand.ExecutableFromString(
fmt.Sprintf("git diff --color %s %s", gui.diffStr(), filterArg), fmt.Sprintf("git diff --color %s", gui.diffStr()),
) )
task := gui.createRunPtyTask(cmd) task := gui.createRunPtyTask(cmd)
@ -100,6 +94,8 @@ func (gui *Gui) diffStr() string {
file := gui.currentlySelectedFilename() file := gui.currentlySelectedFilename()
if file != "" { if file != "" {
output += " -- " + file output += " -- " + file
} else if gui.State.Modes.Filtering.Active() {
output += " -- " + gui.State.Modes.Filtering.Path
} }
return output return output