|  | 
| 9 | 9 | 	"time" | 
| 10 | 10 | 
 | 
| 11 | 11 | 	"github.com/jesseduffield/gocui" | 
|  | 12 | +	"github.com/jesseduffield/lazygit/pkg/commands/oscommands" | 
| 12 | 13 | 	"github.com/jesseduffield/lazygit/pkg/utils" | 
| 13 | 14 | 	"github.com/sasha-s/go-deadlock" | 
| 14 | 15 | 	"github.com/sirupsen/logrus" | 
| @@ -165,7 +166,22 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p | 
| 165 | 166 | 				// and the user is flicking through a bunch of items. | 
| 166 | 167 | 				self.throttle = time.Since(startTime) < THROTTLE_TIME && timeToStart > COMMAND_START_THRESHOLD | 
| 167 | 168 | 
 | 
| 168 |  | -				// close the task's stdout pipe (or the pty if we're using one) to make the command terminate | 
|  | 169 | +				// Kill the still-running command. We only need to do this for the case that the git | 
|  | 170 | +				// command is not yet done producing the initial part of the output; this can happen | 
|  | 171 | +				// for very long diffs when diff.algorithm = histogram is being used. In this case, | 
|  | 172 | +				// closing the output pipe will cause the git command to terminate only the next | 
|  | 173 | +				// time it tries to output something, which might still take a while. But we want to | 
|  | 174 | +				// kill it immediately, so that we can show the next thing the user selected without | 
|  | 175 | +				// delay. | 
|  | 176 | +				// | 
|  | 177 | +				// Unfortunately this will do nothing on Windows, so we'll have to live with the | 
|  | 178 | +				// delay there. | 
|  | 179 | +				if err := oscommands.TerminateProcessGracefully(cmd); err != nil { | 
|  | 180 | +					self.Log.Errorf("error when trying to terminate cmd task: %v; Command: %v %v", err, cmd.Path, cmd.Args) | 
|  | 181 | +				} | 
|  | 182 | + | 
|  | 183 | +				// close the task's stdout pipe (or the pty if we're using one) to make the command | 
|  | 184 | +				// terminate on Windows, and so that the Wait call below doesn't block. | 
| 169 | 185 | 				onDone() | 
| 170 | 186 | 			} | 
| 171 | 187 | 		}) | 
|  | 
0 commit comments