mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
more things
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/aybabtme/humanlog"
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_config"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
@@ -284,13 +285,9 @@ func (app *App) Rebase() error {
|
||||
|
||||
// Close closes any resources
|
||||
func (app *App) Close() error {
|
||||
for _, closer := range app.closers {
|
||||
err := closer.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return slices.TryForEach(app.closers, func(closer io.Closer) error {
|
||||
return closer.Close()
|
||||
})
|
||||
}
|
||||
|
||||
// KnownError takes an error and tells us whether it's an error that we know about where we can print a nicely formatted version of it rather than panicking with a stack trace
|
||||
@@ -299,10 +296,10 @@ func (app *App) KnownError(err error) (string, bool) {
|
||||
|
||||
knownErrorMessages := []string{app.Tr.MinGitVersionError}
|
||||
|
||||
for _, message := range knownErrorMessages {
|
||||
if errorMessage == message {
|
||||
return message, true
|
||||
}
|
||||
if message, ok := slices.Find(knownErrorMessages, func(knownErrorMessage string) bool {
|
||||
return knownErrorMessage == errorMessage
|
||||
}); ok {
|
||||
return message, true
|
||||
}
|
||||
|
||||
mappings := []errorMapping{
|
||||
@@ -312,11 +309,12 @@ func (app *App) KnownError(err error) (string, bool) {
|
||||
},
|
||||
}
|
||||
|
||||
for _, mapping := range mappings {
|
||||
if strings.Contains(errorMessage, mapping.originalError) {
|
||||
return mapping.newError, true
|
||||
}
|
||||
if mapping, ok := slices.Find(mappings, func(mapping errorMapping) bool {
|
||||
return strings.Contains(errorMessage, mapping.originalError)
|
||||
}); ok {
|
||||
return mapping.newError, true
|
||||
}
|
||||
|
||||
return "", false
|
||||
}
|
||||
|
||||
|
||||
@@ -141,12 +141,11 @@ outer:
|
||||
if existing == nil {
|
||||
contextAndViewBindingMap[key] = []*types.Binding{binding}
|
||||
} else {
|
||||
for _, navBinding := range contextAndViewBindingMap[key] {
|
||||
if navBinding.Description == binding.Description {
|
||||
continue outer
|
||||
}
|
||||
if !slices.Some(contextAndViewBindingMap[key], func(navBinding *types.Binding) bool {
|
||||
return navBinding.Description == binding.Description
|
||||
}) {
|
||||
contextAndViewBindingMap[key] = append(contextAndViewBindingMap[key], binding)
|
||||
}
|
||||
contextAndViewBindingMap[key] = append(contextAndViewBindingMap[key], binding)
|
||||
}
|
||||
|
||||
continue outer
|
||||
|
||||
@@ -3,15 +3,14 @@ package gui
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/constants"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
)
|
||||
|
||||
func (gui *Gui) informationStr() string {
|
||||
for _, mode := range gui.modeStatuses() {
|
||||
if mode.isActive() {
|
||||
return mode.description()
|
||||
}
|
||||
if activeMode, ok := gui.getActiveMode(); ok {
|
||||
return activeMode.description()
|
||||
}
|
||||
|
||||
if gui.g.Mouse {
|
||||
@@ -23,6 +22,12 @@ func (gui *Gui) informationStr() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) getActiveMode() (modeStatus, bool) {
|
||||
return slices.Find(gui.modeStatuses(), func(mode modeStatus) bool {
|
||||
return mode.isActive()
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleInfoClick() error {
|
||||
if !gui.g.Mouse {
|
||||
return nil
|
||||
@@ -33,13 +38,11 @@ func (gui *Gui) handleInfoClick() error {
|
||||
cx, _ := view.Cursor()
|
||||
width, _ := view.Size()
|
||||
|
||||
for _, mode := range gui.modeStatuses() {
|
||||
if mode.isActive() {
|
||||
if width-cx > len(gui.c.Tr.ResetInParentheses) {
|
||||
return nil
|
||||
}
|
||||
return mode.reset()
|
||||
if activeMode, ok := gui.getActiveMode(); ok {
|
||||
if width-cx > len(gui.c.Tr.ResetInParentheses) {
|
||||
return nil
|
||||
}
|
||||
return activeMode.reset()
|
||||
}
|
||||
|
||||
// if we're not in an active mode we show the donate button
|
||||
|
||||
Reference in New Issue
Block a user