mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 23:56:24 -04:00
Add PostRefreshUpdateWithOptions
This commit is contained in:
parent
fd1b229f93
commit
fa531dc518
|
|
@ -1670,11 +1670,9 @@ func (self *RefreshHelper) refreshView(context types.Context, env refreshEnv) {
|
|||
// the filtered list model is up to date for rendering.
|
||||
self.searchHelper.ReApplyFilter(context)
|
||||
|
||||
if env.keepScrollPosition {
|
||||
self.c.PostRefreshUpdateKeepingScrollPosition(context)
|
||||
} else {
|
||||
self.c.PostRefreshUpdate(context)
|
||||
}
|
||||
self.c.PostRefreshUpdateWithOptions(context, types.OnFocusOpts{
|
||||
KeepScrollPosition: env.keepScrollPosition,
|
||||
})
|
||||
|
||||
self.c.AfterLayout(func() error {
|
||||
// Re-applying the search must be done after re-rendering the view though,
|
||||
|
|
|
|||
|
|
@ -39,11 +39,15 @@ func (self *guiCommon) RefreshFromWorker(opts types.RefreshOptions) {
|
|||
}
|
||||
|
||||
func (self *guiCommon) PostRefreshUpdate(context types.Context) {
|
||||
self.gui.postRefreshUpdate(context, false)
|
||||
self.gui.postRefreshUpdate(context, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
func (self *guiCommon) PostRefreshUpdateWithOptions(context types.Context, opts types.OnFocusOpts) {
|
||||
self.gui.postRefreshUpdate(context, opts)
|
||||
}
|
||||
|
||||
func (self *guiCommon) PostRefreshUpdateKeepingScrollPosition(context types.Context) {
|
||||
self.gui.postRefreshUpdate(context, true)
|
||||
self.gui.postRefreshUpdate(context, types.OnFocusOpts{KeepScrollPosition: true})
|
||||
}
|
||||
|
||||
func (self *guiCommon) RunSubprocessAndRefresh(cmdObj *oscommands.CmdObj) error {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ type IGuiCommon interface {
|
|||
// case would be overkill, although refresh will internally call 'PostRefreshUpdate'.
|
||||
// It re-focuses the context's selection, which scrolls it into view.
|
||||
PostRefreshUpdate(Context)
|
||||
// Like PostRefreshUpdate, with control over scrolling and whether to update
|
||||
// the main view.
|
||||
PostRefreshUpdateWithOptions(Context, OnFocusOpts)
|
||||
// Like PostRefreshUpdate, but leaves the view scrolled where it is. For
|
||||
// refreshes that no user action is behind: those must not move the viewport
|
||||
// away from wherever the user last put it.
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func (gui *Gui) renderContentOnly() {
|
|||
// postRefreshUpdate is to be called on a context after the state that it depends on has been refreshed
|
||||
// if the context's view is set to another context we do nothing.
|
||||
// if the context's view is the current view we trigger a focus; re-selecting the current item.
|
||||
func (gui *Gui) postRefreshUpdate(c types.Context, keepScrollPosition bool) {
|
||||
func (gui *Gui) postRefreshUpdate(c types.Context, opts types.OnFocusOpts) {
|
||||
t := time.Now()
|
||||
defer func() {
|
||||
gui.Log.Infof("postRefreshUpdate for %s took %s", c.GetKey(), time.Since(t))
|
||||
|
|
@ -141,14 +141,14 @@ func (gui *Gui) postRefreshUpdate(c types.Context, keepScrollPosition bool) {
|
|||
c.HandleRender()
|
||||
|
||||
if gui.currentViewName() == c.GetViewName() {
|
||||
c.HandleFocus(types.OnFocusOpts{KeepScrollPosition: keepScrollPosition})
|
||||
c.HandleFocus(opts)
|
||||
} else {
|
||||
// The FocusLine call is included in the HandleFocus method which we
|
||||
// call for focused views above; but we need to call it here for
|
||||
// non-focused views to ensure that an inactive selection is painted
|
||||
// correctly, and that integration tests see the up to date selection
|
||||
// state.
|
||||
c.FocusLine(!keepScrollPosition)
|
||||
c.FocusLine(!opts.KeepScrollPosition)
|
||||
|
||||
currentCtx := gui.State.ContextMgr.Current()
|
||||
if currentCtx.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY || currentCtx.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY {
|
||||
|
|
|
|||
Loading…
Reference in a new issue