mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Read a view that is being searched to the end when it renders again
Opening the search prompt reads the whole of the view's content, so that the search counts every match in it. Rendering the content again reads only as much as the scrollbar needs, so the matches below that point are lost. The "x of y" drops to what the shortened content holds, and grows again as the user scrolls far enough to load more. Read to the end while a search is on, the way opening the prompt does. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0505e778b3
commit
04a7ae3ec8
|
|
@ -25,6 +25,18 @@ func (gui *Gui) linesToReadFromCmdTask(v *gocui.View) tasks.LinesToRead {
|
|||
|
||||
linesForFirstRefresh := height + oy + 10
|
||||
|
||||
// A search counts the matches in everything the view holds, so a re-render of a
|
||||
// view that is being searched is read all the way to the end (as opening the
|
||||
// search prompt reads it, see MainViewController.openSearch). Lines left unread
|
||||
// hold matches the search doesn't know about, and would add themselves to the
|
||||
// "x of y" as the user scrolled far enough to load them.
|
||||
if v.IsSearching() {
|
||||
return tasks.LinesToRead{
|
||||
Total: -1,
|
||||
InitialRefreshAfter: linesForFirstRefresh,
|
||||
}
|
||||
}
|
||||
|
||||
// We want to read as many lines initially as necessary to let the
|
||||
// scrollbar go to its minimum height, so that the scrollbar thumb doesn't
|
||||
// change size as you scroll down.
|
||||
|
|
|
|||
|
|
@ -53,5 +53,14 @@ var SearchALongDiff = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
FilterOrSearch("NEEDLE")
|
||||
|
||||
t.Views().Search().Content(Contains("matches for 'NEEDLE' (1 of 3)"))
|
||||
|
||||
// Rendering the diff again reads it from the start, and it is read all the
|
||||
// way down to the matches the search already knows about.
|
||||
t.Views().Main().
|
||||
Press(keys.Universal.IncreaseContextInDiffView).
|
||||
Tap(func() {
|
||||
t.ExpectToast(Equals("Changed diff context size to 4"))
|
||||
}).
|
||||
Content(Contains("+NEEDLE last"))
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue