mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 13:37:09 -04:00
Lay git's own diff out to the width the layout gives the view
Changing the screen mode renders the main view again, and so does anything else that changes its size along with what it shows. With git's own diff, that render laid a commit's diffstat out to the width the view had before. The graph then wrapped onto rows of its own in a view that got narrower, and stopped short in one that got wider. A diff renderer's render is created after the layout pass, since only the layout settles the view's size, and takes its width there. git's own diff took its width straight away instead, when the render was asked for. Create its task after the layout as well. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6b38e8fcde
commit
0afb94e97b
@@ -27,11 +27,17 @@ func (gui *Gui) newCmdTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
||||
// thumb to shrink and snap back as the rest loads.
|
||||
view.FreezeScrollbarHeight()
|
||||
|
||||
// Snapshot the view width here, on the UI thread, so the task goroutine
|
||||
// doesn't read the view's live dimensions while it streams output.
|
||||
spec := renderSpec{view: view, cmd: cmd, width: view.InnerWidth()}
|
||||
// The command lays its output out to the width of the view (git's diffstat
|
||||
// graph does), and only the layout settles that, so the task is created after
|
||||
// it, as a diff renderer's is. Taking the width there, on the UI thread, also
|
||||
// keeps the task goroutine from reading the view's live dimensions while it
|
||||
// streams output.
|
||||
gui.afterLayout(func() error {
|
||||
spec := renderSpec{view: view, cmd: cmd, width: view.InnerWidth()}
|
||||
return gui.newTaskForRender(spec, prefix, cmdStr, gui.plainRender)
|
||||
})
|
||||
|
||||
return gui.newTaskForRender(spec, prefix, cmdStr, gui.plainRender)
|
||||
return nil
|
||||
}
|
||||
|
||||
// plainRender runs the command as it is, with its output going straight into
|
||||
|
||||
@@ -49,10 +49,7 @@ var StatFollowsAScreenModeChange = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Main().
|
||||
ContainsViewLines(
|
||||
Contains("file1 | 200"),
|
||||
/* EXPECTED:
|
||||
Contains("1 file changed"),
|
||||
ACTUAL: */
|
||||
MatchesRegexp(`^\++$`),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user