summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDawid Dziurla <dawidd0811@gmail.com>2018-09-09 10:39:08 +0200
committerDawid Dziurla <dawidd0811@gmail.com>2018-09-09 10:41:01 +0200
commit6f7de83bcee20ab14556b95041695b959dfb407b (patch)
treeebedfd0baaa505965bba3efba91e561c679a90b3 /pkg
parente80371fc6f1dbbf826fcf97626eaa4bc445736f9 (diff)
parent5af03b68206fcfe1a22a9a4c74d730d2b1b13603 (diff)
Merge branch 'master' into feature/help
conflicts resolved
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/app.go4
-rw-r--r--pkg/commands/git.go126
-rw-r--r--pkg/commands/git_test.go233
-rw-r--r--pkg/commands/os_test.go4
-rw-r--r--pkg/config/app_config.go3
-rw-r--r--pkg/config/config_linux.go2
-rw-r--r--pkg/gui/commit_message_panel.go56
-rw-r--r--pkg/gui/confirmation_panel.go32
-rw-r--r--pkg/gui/files_panel.go1
-rw-r--r--pkg/gui/gui.go18
-rw-r--r--pkg/gui/keybindings.go5
-rw-r--r--pkg/gui/view_helpers.go22
-rw-r--r--pkg/i18n/dutch.go3
-rw-r--r--pkg/i18n/english.go3
-rw-r--r--pkg/i18n/polish.go3
15 files changed, 391 insertions, 124 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index fa2415fc3..b03ec5b42 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -65,8 +65,8 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
})
}
-// NewApp retruns a new applications
-func NewApp(config config.AppConfigurer) (*App, error) {
+// Setup bootstrap a new application
+func Setup(config config.AppConfigurer) (*App, error) {
app := &App{
closers: []io.Closer{},
Config: config,
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 704a45c73..61c566780 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -15,6 +15,48 @@ import (
gogit "gopkg.in/src-d/go-git.v4"
)
+func verifyInGitRepo(runCmd func(string) error) error {
+ return runCmd("git status")
+}
+
+func navigateToRepoRootDirectory(stat func(string) (os.FileInfo, error), chdir func(string) error) error {
+ for {
+ f, err := stat(".git")
+
+ if err == nil && f.IsDir() {
+ return nil
+ }
+
+ if !os.IsNotExist(err) {
+ return err
+ }
+
+ if err = chdir(".."); err != nil {
+ return err
+ }
+ }
+}
+
+func setupRepositoryAndWorktree(openGitRepository func(string) (*gogit.Repository, error), sLocalize func(string) string) (repository *gogit.Repository, worktree *gogit.Worktree, err error) {
+ repository, err = openGitRepository(".")
+
+ if err != nil {
+ if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) {
+ return nil, nil, errors.New(sLocalize("GitconfigParseErr"))
+ }
+
+ return
+ }
+
+ worktree, err = repository.Worktree()
+
+ if err != nil {
+ return
+ }
+
+ return
+}
+
// GitCommand is our main git interface
type GitCommand struct {
Log *logrus.Entry
@@ -26,22 +68,36 @@ type GitCommand struct {
// NewGitCommand it runs git commands
func NewGitCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer) (*GitCommand, error) {
- gitCommand := &GitCommand{
- Log: log,
- OSCommand: osCommand,
- Tr: tr,
+ var worktree *gogit.Worktree
+ var repo *gogit.Repository
+
+ fs := []func() error{
+ func() error {
+ return verifyInGitRepo(osCommand.RunCommand)
+ },
+ func() error {
+ return navigateToRepoRootDirectory(os.Stat, os.Chdir)
+ },
+ func() error {
+ var err error
+ repo, worktree, err = setupRepositoryAndWorktree(gogit.PlainOpen, tr.SLocalize)
+ return err
+ },
}
- return gitCommand, nil
-}
-// SetupGit sets git repo up
-func (c *GitCommand) SetupGit() {
- c.verifyInGitRepo()
- c.navigateToRepoRootDirectory()
- if err := c.setupWorktree(); err != nil {
- c.Log.Error(err)
- panic(err)
+ for _, f := range fs {
+ if err := f(); err != nil {
+ return nil, err
+ }
}
+
+ return &GitCommand{
+ Log: log,
+ OSCommand: osCommand,
+ Tr: tr,
+ Worktree: worktree,
+ Repo: repo,
+ }, nil
}
// GetStashEntries stash entryies
@@ -145,46 +201,11 @@ func (c *GitCommand) MergeStatusFiles(oldFiles, newFiles []File) []File {
return append(headResults, tailResults...)
}
-func (c *GitCommand) verifyInGitRepo() {
- if output, err := c.OSCommand.RunCommandWithOutput("git status"); err != nil {
- fmt.Println(output)
- os.Exit(1)
- }
-}
-
// GetBranchName branch name
func (c *GitCommand) GetBranchName() (string, error) {
return c.OSCommand.RunCommandWithOutput("git symbolic-ref --short HEAD")
}
-func (c *GitCommand) navigateToRepoRootDirectory() {
- _, err := os.Stat(".git")
- for os.IsNotExist(err) {
- c.Log.Debug("going up a directory to find the root")
- os.Chdir("..")
- _, err = os.Stat(".git")
- }
-}
-
-func (c *GitCommand) setupWorktree() error {
- r, err := gogit.PlainOpen(".")
- if err != nil {
- if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) {
- errorMessage := c.Tr.SLocalize("GitconfigParseErr")
- return errors.New(errorMessage)
- }
- return err
- }
- c.Repo = r
-
- w, err := r.Worktree()
- if err != nil {
- return err
- }
- c.Worktree = w
- return nil
-}
-
// ResetHard does the equivalent of `git reset --hard HEAD`
func (c *GitCommand) ResetHard() error {
return c.Worktree.Reset(&gogit.ResetOptions{Mode: gogit.HardReset})
@@ -434,15 +455,6 @@ func (c *GitCommand) GetBranchGraph(branchName string) (string, error) {
return c.OSCommand.RunCommandWithOutput("git log --graph --color --abbrev-commit --decorate --date=relative --pretty=medium -100 " + branchName)
}
-// Map (from https://gobyexample.com/collection-functions)
-func Map(vs []string, f func(string) string) []string {
- vsm := make([]string, len(vs))
- for i, v := range vs {
- vsm[i] = f(v)
- }
- return vsm
-}
-
func includesString(list []string, a string) bool {
for _, b := range list {
if b == a {
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index fb3bafe6c..777eebaec 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -1,15 +1,53 @@
package commands
import (
+ "fmt"
"io/ioutil"
+ "os"
"os/exec"
"testing"
+ "time"
+ "github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/test"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
+ gogit "gopkg.in/src-d/go-git.v4"
)
+type fileInfoMock struct {
+ name string
+ size int64
+ fileMode os.FileMode
+ fileModTime time.Time
+ isDir bool
+ sys interface{}
+}
+
+func (f fileInfoMock) Name() string {
+ return f.name
+}
+
+func (f fileInfoMock) Size() int64 {
+ return f.size
+}
+
+func (f fileInfoMock) Mode() os.FileMode {
+ return f.fileMode
+}
+
+func (f fileInfoMock) ModTime() time.Time {
+ return f.fileModTime
+}
+
+func (f fileInfoMock) IsDir() bool {
+ return f.isDir
+}
+
+func (f fileInfoMock) Sys() interface{} {
+ return f.sys
+}
+
func newDummyLog() *logrus.Entry {
log := logrus.New()
log.Out = ioutil.Discard
@@ -20,6 +58,201 @@ func newDummyGitCommand() *GitCommand {
return &GitCommand{
Log: newDummyLog(),
OSCommand: newDummyOSCommand(),
+ Tr: i18n.NewLocalizer(newDummyLog()),
+ }
+}
+
+func TestVerifyInGitRepo(t *testing.T) {
+ type scenario struct {
+ runCmd func(string) error
+ test func(error)
+ }
+
+ scenarios := []scenario{
+ {
+ func(string) error {
+ return nil
+ },
+ func(err error) {
+ assert.NoError(t, err)
+ },
+ },
+ {
+ func(string) error {
+ return fmt.Errorf("fatal: Not a git repository (or any of the parent directories): .git")
+ },
+ func(err error) {
+ assert.Error(t, err)
+ assert.Regexp(t, "fatal: .ot a git repository \\(or any of the parent directories\\): \\.git", err.Error())
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s.test(verifyInGitRepo(s.runCmd))
+ }
+}
+
+func TestNavigateToRepoRootDirectory(t *testing.T) {
+ type scenario struct {
+ stat func(string) (os.FileInfo, error)
+ chdir func(string) error
+ test func(error)
+ }
+
+ scenarios := []scenario{
+ {
+ func(string) (os.FileInfo, error) {
+ return fileInfoMock{isDir: true}, nil
+ },
+ func(string) error {
+ return nil
+ },
+ func(err error) {
+ assert.NoError(t, err)
+ },
+ },
+ {
+ func(string) (os.FileInfo, error) {
+ return nil, fmt.Errorf("An error occurred")
+ },
+ func(string) error {
+ return nil
+ },
+ func(err error) {
+ assert.Error(t, err)
+ assert.EqualError(t, err, "An error occurred")
+ },
+ },
+ {
+ func(string) (os.FileInfo, error) {
+ return nil, os.ErrNotExist
+ },
+ func(string) error {
+ return fmt.Errorf("An error occurred")
+ },
+ func(err error) {
+ assert.Error(t, err)
+ assert.EqualError(t, err, "An error occurred")
+ },
+ },
+ {
+ func(string) (os.FileInfo, error) {
+ return nil, os.ErrNotExist
+ },
+ func(string) error {
+ return fmt.Errorf("An error occurred")
+ },
+ func(err error) {
+ assert.Error(t, err)
+ assert.EqualError(t, err, "An error occurred")
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s.test(navigateToRepoRootDirectory(s.stat, s.chdir))
+ }
+}
+
+func TestSetupRepositoryAndWorktree(t *testing.T) {
+ type scenario struct {
+ openGitRepository func(string) (*gogit.Repository, error)
+ sLocalize func(string) string
+ test func(*gogit.Repository, *gogit.Worktree, error)
+ }
+
+ scenarios := []scenario{
+ {
+ func(string) (*gogit.Repository, error) {
+ return nil, fmt.Errorf(`unquoted '\' must be followed by new line`)
+ },
+ func(string) string {
+ return "error translated"
+ },
+ func(r *gogit.Repository, w *gogit.Worktree, err error) {
+ assert.Error(t, err)
+ assert.EqualError(t, err, "error translated")
+ },
+ },
+ {
+ func(string) (*gogit.Repository, error) {
+ return nil, fmt.Errorf("Error from inside gogit")
+ },
+ func(string) string { return "" },
+ func(r *gogit.Repository, w *gogit.Worktree, err error) {
+ assert.Error(t, err)
+ assert.EqualError(t, err, "Error from inside gogit")
+ },
+ },
+ {
+ func(string) (*gogit.Repository, error) {
+ return &gogit.Repository{}, nil
+ },
+ func(string) string { return "" },
+ func(r *gogit.Repository, w *gogit.Worktree, err error) {
+ assert.Error(t, err)
+ assert.Equal(t, gogit.ErrIsBareRepository, err)
+ },
+ },
+ {
+ func(string) (*gogit.Repository, error) {
+ assert.NoError(t, os.RemoveAll("/tmp/lazygit-test"))
+ r, err := gogit.PlainInit("/tmp/lazygit-test", false)
+ assert.NoError(t, err)
+ return r, nil
+ },
+ func(string) string { return "" },
+ func(r *gogit.Repository, w *gogit.Worktree, err error) {
+ assert.NoError(t, err)
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s.test(setupRepositoryAndWorktree(s.openGitRepository, s.sLocalize))
+ }
+}
+
+func TestNewGitCommand(t *testing.T) {
+ actual, err := os.Getwd()
+ assert.NoError(t, err)
+
+ defer func() {
+ assert.NoError(t, os.Chdir(actual))
+ }()
+
+ type scenario struct {
+ setup func()
+ test func(*GitCommand, error)
+ }
+
+ scenarios := []scenario{
+ {
+ func() {
+ assert.NoError(t, os.Chdir("/tmp"))
+ },
+ func(gitCmd *GitCommand, err error) {
+ assert.Error(t, err)
+ assert.Regexp(t, "fatal: .ot a git repository \\(or any of the parent directories\\): \\.git", err.Error())
+ },
+ },
+ {
+ func() {
+ assert.NoError(t, os.RemoveAll("/tmp/lazygit-test"))
+ _, err := gogit.PlainInit("/tmp/lazygit-test", false)
+ assert.NoError(t, err)
+ assert.NoError(t, os.Chdir("/tmp/lazygit-test"))
+ },
+ func(gitCmd *GitCommand, err error) {
+ assert.NoError(t, err)
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s.setup()
+ s.test(NewGitCommand(newDummyLog(), newDummyOSCommand(), i18n.NewLocalizer(newDummyLog())))
}
}
diff --git a/pkg/commands/os_test.go b/pkg/commands/os_test.go
index 5d1644a38..01173fb15 100644
--- a/pkg/commands/os_test.go
+++ b/pkg/commands/os_test.go
@@ -46,7 +46,7 @@ func TestOSCommandRunCommandWithOutput(t *testing.T) {
{
"rmdir unexisting-folder",
func(output string, err error) {
- assert.Regexp(t, "rmdir: .* 'unexisting-folder': .*", err.Error())
+ assert.Regexp(t, "rmdir.*unexisting-folder.*", err.Error())
},
},
}
@@ -66,7 +66,7 @@ func TestOSCommandRunCommand(t *testing.T) {
{
"rmdir unexisting-folder",
func(err error) {
- assert.Regexp(t, "rmdir: .* 'unexisting-folder': .*", err.Error())
+ assert.Regexp(t, "rmdir.*unexisting-folder.*", err.Error())
},
},
}
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index 3c272e520..7cde63de1 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -222,10 +222,13 @@ func GetDefaultConfig() []byte {
- white
optionsTextColor:
- blue
+ commitLength:
+ show: true
update:
method: prompt # can be: prompt | background | never
days: 14 # how often a update is checked for
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
+confirmOnQuit: false
`)
}
diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go
index ef30ac7d2..90e922416 100644
--- a/pkg/config/config_linux.go
+++ b/pkg/config/config_linux.go
@@ -4,5 +4,5 @@ package config
func GetPlatformDefaultConfig() []byte {
return []byte(
`os:
- openCommand: 'bash -c \"xdg-open {{filename}} &>/dev/null &\"'`)
+ openCommand: 'sh -c "xdg-open {{filename}} >/dev/null"'`)
}
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index 26db703f0..99d649102 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -1,6 +1,9 @@
package gui
import (
+ "strconv"
+ "strings"
+
"github.com/jesseduffield/gocui"
)
@@ -33,20 +36,6 @@ func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error {
return gui.switchFocus(g, v, gui.getFilesView(g))
}
-func (gui *Gui) handleNewlineCommitMessage(g *gocui.Gui, v *gocui.View) error {
- // resising ahead of time so that the top line doesn't get hidden to make
- // room for the cursor on the second line
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Buffer())
- if _, err := g.SetView("commitMessage", x0, y0, x1, y1+1, 0); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- }
-
- v.EditNewLine()
- return nil
-}
-
func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error {
message := gui.Tr.TemplateLocalize(
"CloseConfirm",
@@ -57,3 +46,42 @@ func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error {
)
return gui.renderString(g, "options", message)
}
+
+func (gui *Gui) simpleEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
+ switch {
+ case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
+ v.EditDelete(true)
+ case key == gocui.KeyDelete:
+ v.EditDelete(false)
+ case key == gocui.KeyArrowDown:
+ v.MoveCursor(0, 1, false)
+ case key == gocui.KeyArrowUp:
+ v.MoveCursor(0, -1, false)
+ case key == gocui.KeyArrowLeft:
+ v.MoveCursor(-1, 0, false)
+ case key == gocui.KeyArrowRight:
+ v.MoveCursor(1, 0, false)
+ case key == gocui.KeyTab:
+ v.EditNewLine()
+ case key == gocui.KeySpace:
+ v.EditWrite(' ')
+ case key == gocui.KeyInsert:
+ v.Overwrite = !v.Overwrite
+ default:
+ v.EditWrite(ch)
+ }
+
+ gui.RenderCommitLength()
+}
+
+func (gui *Gui) getBufferLength(view *gocui.View) string {
+ return " " + strconv.Itoa(strings.Count(view.Buffer(), "")-1) + " "
+}
+
+func (gui *Gui) RenderCommitLength() {
+ if !gui.Config.GetUserConfig().GetBool("gui.commitLength.show") {
+ return
+ }
+ v := gui.getCommitMessageView(gui.g)
+ v.Subtitle = gui.getBufferLength(v)
+}
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index 1702b1df6..58577e430 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -11,7 +11,6 @@ import (
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) wrappedConfirmationFunction(function func(*gocui.Gui, *gocui.View) error) func(*gocui.Gui, *gocui.View) error {
@@ -116,20 +115,6 @@ func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, t
return nil
}
-func (gui *Gui) handleNewline(g *gocui.Gui, v *gocui.View) error {
- // resising ahead of time so that the top line doesn't get hidden to make
- // room for the cursor on the second line
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Buffer())
- if _, err := g.SetView("confirmation", x0, y0, x1, y1+1, 0); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- }
-
- v.EditNewLine()
- return nil
-}
-
func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
actions := gui.Tr.TemplateLocalize(
"CloseConfirm",
@@ -144,9 +129,6 @@ func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*go
if err := g.SetKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone, gui.wrappedConfirmationFunction(handleConfirm)); err != nil {
return err
}
- if err := g.SetKeybinding("confirmation", gocui.KeyTab, gocui.ModNone, gui.handleNewline); err != nil {
- return err
- }
return g.SetKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone, gui.wrappedConfirmationFunction(handleClose))
}
@@ -161,17 +143,3 @@ func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error {
coloredMessage := colorFunction(strings.TrimSpace(message))
return gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil)
}
-
-func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
- // If the confirmation panel is already displayed, just resize the width,
- // otherwise continue
- content := utils.TrimTrailingNewline(v.Buffer())
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
- vx0, vy0, vx1, vy1 := v.Dimensions()
- if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
- return nil
- }
- gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
- _, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
- return err
-}
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 52366304b..bfcc938bb 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -202,6 +202,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
g.Update(func(g *gocui.Gui) error {
g.SetViewOnTop("commitMessage")
gui.switchFocus(g, filesView, commitMessageView)
+ gui.RenderCommitLength()
return nil
})
return nil
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index c27b77da3..e3cc61529 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -263,6 +263,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
commitMessageView.Title = gui.Tr.SLocalize("CommitMessage")
commitMessageView.FgColor = gocui.ColorWhite
commitMessageView.Editable = true
+ commitMessageView.Editor = gocui.EditorFunc(gui.simpleEditor)
}
}
@@ -308,9 +309,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
}
- gui.resizePopupPanels(g)
-
- return nil
+ return gui.resizeCurrentPopupPanel(g)
}
func (gui *Gui) promptAnonymousReporting() error {
@@ -365,14 +364,6 @@ func (gui *Gui) goEvery(g *gocui.Gui, interval time.Duration, function func(*goc
}()
}
-func (gui *Gui) resizePopupPanels(g *gocui.Gui) error {
- v := g.CurrentView()
- if v.Name() == "commitMessage" || v.Name() == "confirmation" {
- return gui.resizePopupPanel(g, v)
- }
- return nil
-}
-
// Run setup the gui with keybindings and start the mainloop
func (gui *Gui) Run() error {
g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges)
@@ -430,5 +421,10 @@ func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error {
if gui.State.Updating {
return gui.createUpdateQuitConfirmation(g, v)
}
+ if gui.Config.GetUserConfig().GetBool("confirmOnQuit") {
+ return gui.createConfirmationPanel(g, v, "", gui.Tr.SLocalize("ConfirmQuit"), func(g *gocui.Gui, v *gocui.View) error {
+ return gocui.ErrQuit
+ }, nil)
+ }
return gocui.ErrQuit
}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 7f07893b7..c8ed7d3c8 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -340,11 +340,6 @@ func (gui *Gui) GetKeybindings() []Binding {
Modifier: gocui.ModNone,
Handler: gui.handleCommitClose,
}, {
- ViewName: "commitMessage",
- Key: gocui.KeyTab,
- Modifier: gocui.ModNone,
- Handler: gui.handleNewlineCommitMessage,
- }, {
ViewName: "menu",
Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 88b74d12e..7a5bd8874 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -277,3 +277,25 @@ func (gui *Gui) currentViewName(g *gocui.Gui) string {
currentView := g.CurrentView()
return currentView.Name()
}
+
+func (gui *Gui) resizeCurrentPopupPanel(g *gocui.Gui) error {
+ v := g.CurrentView()
+ if v.Name() == "commitMessage" || v.Name() == "confirmation" {
+ return gui.resizePopupPanel(g, v)
+ }
+ return nil
+}
+
+func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
+ // If the confirmation panel is already displayed, just resize the width,
+ // otherwise continue
+ content := v.Buffer()
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
+ vx0, vy0, vx1, vy1 := v.Dimensions()
+ if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
+ return nil
+ }
+ gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
+ _, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
+ return err
+}
diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go
index 7a3ba16b0..21330e55c 100644
--- a/pkg/i18n/dutch.go
+++ b/pkg/i18n/dutch.go
@@ -367,6 +367,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`,
+ }, &i18n.Message{
+ ID: "ConfirmQuit",
+ Other: `Are you sure you want to quit?`,
},
)
}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index c92d5510a..677fa295b 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -387,6 +387,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`,
+ }, &i18n.Message{
+ ID: "ConfirmQuit",
+ Other: `Are you sure you want to quit?`,
},
)
}
diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go
index 0e3702f43..c64ab87b8 100644
--- a/pkg/i18n/polish.go
+++ b/pkg/i18n/polish.go
@@ -365,6 +365,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `scal do obecnej gałęzi`,
+ }, &i18n.Message{
+ ID: "ConfirmQuit",
+ Other: `Na pewno chcesz wyjść z programu?`,
},
)
}