diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-10-02 20:31:40 -0700 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-10-02 20:41:24 -0700 |
commit | e76fa5a6cb648f8c3b642d83368ea08a48ab43b0 (patch) | |
tree | b5e7fd56f0e3bad837608c0c76c63394df308c96 /pkg/gui/main_panels.go | |
parent | a77aa4d75ae1f04a15257fd92f7e763b8a4215db (diff) |
fix glitchy render of stale data when flicking through files and directories
Diffstat (limited to 'pkg/gui/main_panels.go')
-rw-r--r-- | pkg/gui/main_panels.go | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 625391480..9e36c18e9 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -27,11 +27,35 @@ func (gui *Gui) runTaskForView(view *gocui.View, task types.UpdateTask) error { } func (gui *Gui) moveMainContextPairToTop(pair types.MainContextPair) { - gui.setWindowContext(pair.Main) - gui.moveToTopOfWindow(pair.Main) + gui.moveMainContextToTop(pair.Main) if pair.Secondary != nil { - gui.setWindowContext(pair.Secondary) - gui.moveToTopOfWindow(pair.Secondary) + gui.moveMainContextToTop(pair.Secondary) + } +} + +func (gui *Gui) moveMainContextToTop(context types.Context) { + gui.setWindowContext(context) + + view := context.GetView() + + topView := gui.topViewInWindow(context.GetWindowName()) + if topView == nil { + gui.Log.Error("unexpected: topView is nil") + return + } + + if topView != view { + // We need to copy the content to avoid a flicker effect: If we're flicking + // through files in the files panel, we use a different view to render the + // files vs the directories, and if you select dir A, then file B, then dir + // C, you'll briefly see dir A's contents again before the view is updated. + // So here we're copying the content from the top window to avoid that + // flicker effect. + gui.g.CopyContent(topView, view) + + if err := gui.g.SetViewOnTopOf(view.Name(), topView.Name()); err != nil { + gui.Log.Error(err) + } } } |