mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
Fall back to WithWaitingStatus if item is scrolled out of view
This commit is contained in:
parent
0fd4983c66
commit
f99c59b6d5
@ -97,3 +97,16 @@ func (self *ListContextTrait) OnSearchSelect(selectedLineIdx int) error {
|
|||||||
self.GetList().SetSelectedLineIdx(selectedLineIdx)
|
self.GetList().SetSelectedLineIdx(selectedLineIdx)
|
||||||
return self.HandleFocus(types.OnFocusOpts{})
|
return self.HandleFocus(types.OnFocusOpts{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ListContextTrait) IsItemVisible(item types.HasUrn) bool {
|
||||||
|
startIdx, length := self.GetViewTrait().ViewPortYBounds()
|
||||||
|
selectionStart := self.ViewIndexToModelIndex(startIdx)
|
||||||
|
selectionEnd := self.ViewIndexToModelIndex(startIdx + length)
|
||||||
|
for i := selectionStart; i < selectionEnd; i++ {
|
||||||
|
iterItem := self.GetList().GetItem(i)
|
||||||
|
if iterItem != nil && iterItem.URN() == item.URN() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import "github.com/jesseduffield/lazygit/pkg/gui/context/traits"
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/context/traits"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
)
|
||||||
|
|
||||||
type ListViewModel[T any] struct {
|
type ListViewModel[T any] struct {
|
||||||
*traits.ListCursor
|
*traits.ListCursor
|
||||||
@ -36,3 +39,8 @@ func (self *ListViewModel[T]) GetItems() []T {
|
|||||||
func Zero[T any]() T {
|
func Zero[T any]() T {
|
||||||
return *new(T)
|
return *new(T)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ListViewModel[T]) GetItem(index int) types.HasUrn {
|
||||||
|
item := self.getModel()[index]
|
||||||
|
return any(item).(types.HasUrn)
|
||||||
|
}
|
||||||
|
@ -64,10 +64,10 @@ func (self inlineStatusHelperTask) Continue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(gocui.Task) error) {
|
func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(gocui.Task) error) {
|
||||||
context := self.c.ContextForKey(opts.ContextKey)
|
context := self.c.ContextForKey(opts.ContextKey).(types.IListContext)
|
||||||
view := context.GetView()
|
view := context.GetView()
|
||||||
visible := view.Visible && self.windowHelper.TopViewInWindow(context.GetWindowName()) == view
|
visible := view.Visible && self.windowHelper.TopViewInWindow(context.GetWindowName()) == view
|
||||||
if visible {
|
if visible && context.IsItemVisible(opts.Item) {
|
||||||
self.c.OnWorker(func(task gocui.Task) {
|
self.c.OnWorker(func(task gocui.Task) {
|
||||||
self.start(opts)
|
self.start(opts)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package filetree
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -69,6 +70,11 @@ func (self *CommitFileTree) Len() int {
|
|||||||
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *CommitFileTree) GetItem(index int) types.HasUrn {
|
||||||
|
// Unimplemented because we don't yet need to show inlines statuses in commit file views
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (self *CommitFileTree) GetAllFiles() []*models.CommitFile {
|
func (self *CommitFileTree) GetAllFiles() []*models.CommitFile {
|
||||||
return self.getFiles()
|
return self.getFiles()
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -24,6 +25,7 @@ type ITree[T any] interface {
|
|||||||
ToggleShowTree()
|
ToggleShowTree()
|
||||||
GetIndexForPath(path string) (int, bool)
|
GetIndexForPath(path string) (int, bool)
|
||||||
Len() int
|
Len() int
|
||||||
|
GetItem(index int) types.HasUrn
|
||||||
SetTree()
|
SetTree()
|
||||||
IsCollapsed(path string) bool
|
IsCollapsed(path string) bool
|
||||||
ToggleCollapsed(path string)
|
ToggleCollapsed(path string)
|
||||||
@ -139,6 +141,11 @@ func (self *FileTree) Len() int {
|
|||||||
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *FileTree) GetItem(index int) types.HasUrn {
|
||||||
|
// Unimplemented because we don't yet need to show inlines statuses in commit file views
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (self *FileTree) GetAllFiles() []*models.File {
|
func (self *FileTree) GetAllFiles() []*models.File {
|
||||||
return self.getFiles()
|
return self.getFiles()
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ type IListContext interface {
|
|||||||
Context
|
Context
|
||||||
|
|
||||||
GetSelectedItemId() string
|
GetSelectedItemId() string
|
||||||
|
IsItemVisible(item HasUrn) bool
|
||||||
|
|
||||||
GetList() IList
|
GetList() IList
|
||||||
ViewIndexToModelIndex(int) int
|
ViewIndexToModelIndex(int) int
|
||||||
@ -215,6 +216,7 @@ type IController interface {
|
|||||||
type IList interface {
|
type IList interface {
|
||||||
IListCursor
|
IListCursor
|
||||||
Len() int
|
Len() int
|
||||||
|
GetItem(index int) HasUrn
|
||||||
}
|
}
|
||||||
|
|
||||||
type IListCursor interface {
|
type IListCursor interface {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user