1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-08 04:04:22 +02:00

Return only visible views from TopViewInWindow

Without this it's not reliably possible to ask whether a given view is visible
by asking

  windowHelper.TopViewInWindow(context.GetWindowName()) == context.GetView()

because there could be transient, invisible contexts after it in the Z order.

I guess it's a bit of a coincidence that this has never been a problem so far.
This commit is contained in:
Stefan Haller 2023-10-19 19:07:36 +02:00
parent cf82e69bbe
commit 240948b882
2 changed files with 3 additions and 7 deletions

View File

@ -92,7 +92,7 @@ func (self *WindowHelper) MoveToTopOfWindow(context types.Context) {
topView := self.TopViewInWindow(window)
if view.Name() != topView.Name() {
if topView != nil && view.Name() != topView.Name() {
if err := self.c.GocuiGui().SetViewOnTopOf(view.Name(), topView.Name()); err != nil {
self.c.Log.Error(err)
}
@ -106,7 +106,7 @@ func (self *WindowHelper) TopViewInWindow(windowName string) *gocui.View {
// The views list is ordered highest-last, so we're grabbing the last view of the window
var topView *gocui.View
for _, currentView := range self.c.GocuiGui().Views() {
if lo.Contains(viewNamesInWindow, currentView.Name()) {
if lo.Contains(viewNamesInWindow, currentView.Name()) && currentView.Visible {
topView = currentView
}
}

View File

@ -39,12 +39,8 @@ func (gui *Gui) moveMainContextToTop(context types.Context) {
view := context.GetView()
topView := gui.helpers.Window.TopViewInWindow(context.GetWindowName())
if topView == nil {
gui.Log.Error("unexpected: topView is nil")
return
}
if topView != view {
if topView != nil && 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