Skip to content

Commit 293846b

Browse files
committed
Draw only visible part of the reflogs panel
Since the reflog can get very long, this saves some memory but especially some UI thread lag. In one of my repos I had over 11'000 reflog entries (I guess I should prune them more regularly...), and rendering them took ~600ms; since this happens on the UI thread, there was an annoying stall for half a second after every background fetch, for example.
1 parent 0adfb77 commit 293846b

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

pkg/gui/context/reflog_commits_context.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
2626
},
2727
)
2828

29-
getDisplayStrings := func(_ int, _ int) [][]string {
29+
getDisplayStrings := func(startIdx int, endIdx int) [][]string {
30+
commits := viewModel.GetItems()
31+
if startIdx >= len(commits) {
32+
return nil
33+
}
34+
3035
return presentation.GetReflogCommitListDisplayStrings(
31-
viewModel.GetItems(),
36+
commits[startIdx:endIdx],
3237
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
3338
c.Modes().CherryPicking.SelectedHashSet(),
3439
c.Modes().Diffing.Ref,
@@ -43,18 +48,20 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
4348
FilteredListViewModel: viewModel,
4449
ListContextTrait: &ListContextTrait{
4550
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
46-
View: c.Views().ReflogCommits,
47-
WindowName: "commits",
48-
Key: REFLOG_COMMITS_CONTEXT_KEY,
49-
Kind: types.SIDE_CONTEXT,
50-
Focusable: true,
51-
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES,
51+
View: c.Views().ReflogCommits,
52+
WindowName: "commits",
53+
Key: REFLOG_COMMITS_CONTEXT_KEY,
54+
Kind: types.SIDE_CONTEXT,
55+
Focusable: true,
56+
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES,
57+
NeedsRerenderOnHeightChange: true,
5258
})),
5359
ListRenderer: ListRenderer{
5460
list: viewModel,
5561
getDisplayStrings: getDisplayStrings,
5662
},
57-
c: c,
63+
c: c,
64+
renderOnlyVisibleLines: true,
5865
},
5966
}
6067
}

0 commit comments

Comments
 (0)