mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-31 23:19:40 +02:00
don't hide transient views upon losing focus
This commit is contained in:
parent
ad7703df65
commit
fe87114074
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) popupViewNames() []string {
|
func (gui *Gui) popupViewNames() []string {
|
||||||
@ -135,10 +134,6 @@ func (gui *Gui) returnFromContext() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) deactivateContext(c types.Context) error {
|
func (gui *Gui) deactivateContext(c types.Context) error {
|
||||||
if c.IsTransient() {
|
|
||||||
gui.resetWindowContext(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
view, _ := gui.g.View(c.GetViewName())
|
view, _ := gui.g.View(c.GetViewName())
|
||||||
|
|
||||||
if view != nil && view.IsSearching() {
|
if view != nil && view.IsSearching() {
|
||||||
@ -150,8 +145,7 @@ func (gui *Gui) deactivateContext(c types.Context) error {
|
|||||||
// if we are the kind of context that is sent to back upon deactivation, we should do that
|
// if we are the kind of context that is sent to back upon deactivation, we should do that
|
||||||
if view != nil &&
|
if view != nil &&
|
||||||
(c.GetKind() == types.TEMPORARY_POPUP ||
|
(c.GetKind() == types.TEMPORARY_POPUP ||
|
||||||
c.GetKind() == types.PERSISTENT_POPUP ||
|
c.GetKind() == types.PERSISTENT_POPUP) {
|
||||||
c.IsTransient()) {
|
|
||||||
view.Visible = false
|
view.Visible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,16 +385,6 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error
|
|||||||
|
|
||||||
_ = oldView.SetOriginX(0)
|
_ = oldView.SetOriginX(0)
|
||||||
|
|
||||||
if !lo.Contains([]*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.Search}, newView) {
|
|
||||||
for _, context := range gui.TransientContexts() {
|
|
||||||
if oldView.Name() == context.GetViewName() {
|
|
||||||
if err := gui.deactivateContext(context); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +459,8 @@ func (gui *Gui) getSideContextSelectedItemId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) isContextVisible(c types.Context) bool {
|
func (gui *Gui) isContextVisible(c types.Context) bool {
|
||||||
return gui.State.WindowViewNameMap[c.GetWindowName()] == c.GetViewName() && gui.State.ViewContextMap.Get(c.GetViewName()).GetKey() == c.GetKey()
|
return gui.State.WindowViewNameMap[c.GetWindowName()] == c.GetViewName() &&
|
||||||
|
gui.State.ViewContextMap.Get(c.GetViewName()).GetKey() == c.GetKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
// currently unused
|
// currently unused
|
||||||
|
@ -33,8 +33,10 @@ type IBaseContext interface {
|
|||||||
SetWindowName(string)
|
SetWindowName(string)
|
||||||
GetKey() ContextKey
|
GetKey() ContextKey
|
||||||
IsFocusable() bool
|
IsFocusable() bool
|
||||||
// if a context is transient, then when it loses focus, its corresponding view
|
// if a context is transient, then it only appears via some keybinding on another
|
||||||
// returns control of the window to the default view for that window
|
// context. Until we add support for having multiple of the same context, no two
|
||||||
|
// of the same transient context can appear at once meaning one might be 'stolen'
|
||||||
|
// from another window.
|
||||||
IsTransient() bool
|
IsTransient() bool
|
||||||
|
|
||||||
// returns the desired title for the view upon activation. If there is no desired title (returns empty string), then
|
// returns the desired title for the view upon activation. If there is no desired title (returns empty string), then
|
||||||
|
@ -25,6 +25,10 @@ func (gui *Gui) setWindowContext(c types.Context) {
|
|||||||
gui.State.WindowViewNameMap = map[string]string{}
|
gui.State.WindowViewNameMap = map[string]string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.IsTransient() {
|
||||||
|
gui.resetWindowContext(c)
|
||||||
|
}
|
||||||
|
|
||||||
gui.State.WindowViewNameMap[c.GetWindowName()] = c.GetViewName()
|
gui.State.WindowViewNameMap[c.GetWindowName()] = c.GetViewName()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +36,12 @@ func (gui *Gui) currentWindow() string {
|
|||||||
return gui.currentContext().GetWindowName()
|
return gui.currentContext().GetWindowName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assumes the context's windowName has been set to the new window if necessary
|
||||||
func (gui *Gui) resetWindowContext(c types.Context) {
|
func (gui *Gui) resetWindowContext(c types.Context) {
|
||||||
// we assume here that the window contains as its default view a view with the same name as the window
|
for windowName, viewName := range gui.State.WindowViewNameMap {
|
||||||
windowName := c.GetWindowName()
|
if viewName == c.GetViewName() && windowName != c.GetWindowName() {
|
||||||
if gui.State.WindowViewNameMap[windowName] == c.GetViewName() {
|
// we assume here that the window contains as its default view a view with the same name as the window
|
||||||
gui.State.WindowViewNameMap[windowName] = windowName
|
gui.State.WindowViewNameMap[windowName] = windowName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user