mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +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:
parent
cf82e69bbe
commit
240948b882
2 changed files with 3 additions and 7 deletions
|
@ -92,7 +92,7 @@ func (self *WindowHelper) MoveToTopOfWindow(context types.Context) {
|
||||||
|
|
||||||
topView := self.TopViewInWindow(window)
|
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 {
|
if err := self.c.GocuiGui().SetViewOnTopOf(view.Name(), topView.Name()); err != nil {
|
||||||
self.c.Log.Error(err)
|
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
|
// The views list is ordered highest-last, so we're grabbing the last view of the window
|
||||||
var topView *gocui.View
|
var topView *gocui.View
|
||||||
for _, currentView := range self.c.GocuiGui().Views() {
|
for _, currentView := range self.c.GocuiGui().Views() {
|
||||||
if lo.Contains(viewNamesInWindow, currentView.Name()) {
|
if lo.Contains(viewNamesInWindow, currentView.Name()) && currentView.Visible {
|
||||||
topView = currentView
|
topView = currentView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,8 @@ func (gui *Gui) moveMainContextToTop(context types.Context) {
|
||||||
view := context.GetView()
|
view := context.GetView()
|
||||||
|
|
||||||
topView := gui.helpers.Window.TopViewInWindow(context.GetWindowName())
|
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
|
// 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
|
// 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
|
// files vs the directories, and if you select dir A, then file B, then dir
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue