diff options
58 files changed, 5263 insertions, 3805 deletions
@@ -11,8 +11,7 @@ require ( github.com/creack/pty v1.1.11 github.com/fatih/color v1.9.0 // indirect github.com/fsnotify/fsnotify v1.4.7 - github.com/gdamore/tcell/v2 v2.4.0 // indirect - github.com/go-errors/errors v1.4.0 + github.com/go-errors/errors v1.4.1 github.com/go-logfmt/logfmt v0.5.0 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.3.2 // indirect @@ -21,7 +20,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 - github.com/jesseduffield/gocui v0.3.1-0.20210927094955-aa62b56c153a + github.com/jesseduffield/gocui v0.3.1-0.20211017041119-0ec562dfd23b github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect @@ -36,11 +35,11 @@ require ( github.com/sahilm/fuzzy v0.1.0 github.com/sirupsen/logrus v1.4.2 github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad - github.com/stretchr/testify v1.6.1 + github.com/stretchr/testify v1.7.0 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect - golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect - golang.org/x/term v0.0.0-20210916214954-140adaaadfaf // indirect + golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect ) @@ -32,16 +32,13 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= -github.com/gdamore/tcell/v2 v2.3.11 h1:ECO6WqHGbKZ3HrSL7bG/zArMCmLaNr5vcjjMVnLHpzc= -github.com/gdamore/tcell/v2 v2.3.11/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57KM= github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= -github.com/go-errors/errors v1.4.0 h1:2OA7MFw38+e9na72T1xgkomPb6GzZzzxvJ5U630FoRM= -github.com/go-errors/errors v1.4.0/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.4.1 h1:IvVlgbzSsaUNudsw5dcXSzF3EWyXTi5XrAdngnuhRyg= +github.com/go-errors/errors v1.4.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= @@ -72,10 +69,10 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= -github.com/jesseduffield/gocui v0.3.1-0.20210614081440-74b42ecad52b h1:Wc2zx6xKLNaHc7/wIO6iYyDSjcFGN1Osd6tQvbgMmgo= -github.com/jesseduffield/gocui v0.3.1-0.20210614081440-74b42ecad52b/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= -github.com/jesseduffield/gocui v0.3.1-0.20210927094955-aa62b56c153a h1:WAxXz26dZbwxmWdFrkKjpuExmgRRVG4l1qKRLKmQZBw= -github.com/jesseduffield/gocui v0.3.1-0.20210927094955-aa62b56c153a/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= +github.com/jesseduffield/gocui v0.3.1-0.20211017035223-b68948e63cc3 h1:J5s/4Y860tas8J0AMQ3gJKCbJPx8zNpiTm5UjEgPQfY= +github.com/jesseduffield/gocui v0.3.1-0.20211017035223-b68948e63cc3/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= +github.com/jesseduffield/gocui v0.3.1-0.20211017041119-0ec562dfd23b h1:kepukaDQfZ6LBSvHUYReFvVSW5Lx5ZQZDgGhXj0Mx7U= +github.com/jesseduffield/gocui v0.3.1-0.20211017041119-0ec562dfd23b/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= github.com/jesseduffield/yaml v2.1.0+incompatible/go.mod h1:w0xGhOSIJCGYYW+hnFPTutCy5aACpkcwbmORt5axGqk= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -109,8 +106,6 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -147,6 +142,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/urfave/cli v1.20.1-0.20180226030253-8e01ec4cd3e2/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= @@ -171,7 +168,6 @@ golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -179,20 +175,14 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= -golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 h1:KzbpndAYEM+4oHRp9JmB2ewj0NHHxO3Z0g7Gus2O1kk= +golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w= -golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= -golang.org/x/term v0.0.0-20210916214954-140adaaadfaf h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI= -golang.org/x/term v0.0.0-20210916214954-140adaaadfaf/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 4c131db20..fb1303a55 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -10,7 +10,7 @@ import ( ) func (gui *Gui) handleCommitConfirm() error { - message := gui.trimmedContent(gui.Views.CommitMessage) + message := strings.TrimSpace(gui.Views.CommitMessage.TextArea.GetContent()) if message == "" { return gui.createErrorPanel(gui.Tr.CommitWithoutMessageErr) } @@ -48,7 +48,7 @@ func (gui *Gui) handleCommitMessageFocused() error { } func (gui *Gui) getBufferLength(view *gocui.View) string { - return " " + strconv.Itoa(strings.Count(view.Buffer(), "")-1) + " " + return " " + strconv.Itoa(strings.Count(view.TextArea.GetContent(), "")-1) + " " } // RenderCommitLength is a function. diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index edcde8821..17838c1f6 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -1,9 +1,5 @@ // lots of this has been directly ported from one of the example files, will brush up later -// Copyright 2014 The gocui Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - package gui import ( @@ -169,7 +165,7 @@ func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, i height/2 + panelHeight/2 } -func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool, findSuggestionsFunc func(string) []*types.Suggestion) error { +func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool, findSuggestionsFunc func(string) []*types.Suggestion, editable bool) error { x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt) // calling SetView on an existing view returns the same view, so I'm not bothering // to reassign to gui.Views.Confirmation @@ -182,7 +178,8 @@ func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool, f gui.g.StartTicking() } gui.Views.Confirmation.Title = title - gui.Views.Confirmation.Wrap = true + // for now we do not support wrapping in our editor + gui.Views.Confirmation.Wrap = !editable gui.Views.Confirmation.FgColor = theme.GocuiDefaultTextColor gui.findSuggestions = findSuggestionsFunc @@ -209,19 +206,27 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error { // remove any previous keybindings gui.clearConfirmationViewKeyBindings() - err := gui.prepareConfirmationPanel(opts.title, opts.prompt, opts.hasLoader, opts.findSuggestionsFunc) + err := gui.prepareConfirmationPanel( + opts.title, + opts.prompt, + opts.hasLoader, + opts.findSuggestionsFunc, + opts.editable, + ) if err != nil { return err } - gui.Views.Confirmation.Editable = opts.editable - gui.Views.Confirmation.Editor = gocui.EditorFunc(gui.defaultEditor) + confirmationView := gui.Views.Confirmation + confirmationView.Editable = opts.editable + confirmationView.Editor = gocui.EditorFunc(gui.defaultEditor) if opts.editable { - if err := gui.Views.Confirmation.SetEditorContent(opts.prompt); err != nil { - return err - } + textArea := confirmationView.TextArea + textArea.Clear() + textArea.TypeString(opts.prompt) + confirmationView.RenderTextArea() } else { - if err := gui.renderStringSync(gui.Views.Confirmation, opts.prompt); err != nil { + if err := gui.renderStringSync(confirmationView, opts.prompt); err != nil { return err } } diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go index ac162ae02..cb814243f 100644 --- a/pkg/gui/credentials_panel.go +++ b/pkg/gui/credentials_panel.go @@ -41,7 +41,7 @@ func (gui *Gui) promptUserForCredential(passOrUname string) string { func (gui *Gui) handleSubmitCredential() error { credentialsView := gui.Views.Credentials - message := gui.trimmedContent(credentialsView) + message := strings.TrimSpace(credentialsView.TextArea.GetContent()) gui.credentials <- message gui.clearEditorView(credentialsView) if err := gui.returnFromContext(); err != nil { diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 7d3054cd0..6cc6409cb 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -6,88 +6,77 @@ import ( "github.com/jesseduffield/gocui" ) -// we've just copy+pasted the editor from gocui to here so that we can also re- -// render the commit message length on each keypress -func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { +func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool { newlineKey, ok := gui.getKey(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline).(gocui.Key) if !ok { newlineKey = gocui.KeyAltEnter } - matched := true switch { case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: - v.EditDelete(true) + textArea.BackSpaceChar() case key == gocui.KeyCtrlD || key == gocui.KeyDelete: - v.EditDelete(false) + textArea.DeleteChar() case key == gocui.KeyArrowDown: - v.MoveCursor(0, 1, false) + textArea.MoveCursorDown() case key == gocui.KeyArrowUp: - v.MoveCursor(0, -1, false) + textArea.MoveCursorUp() case key == gocui.KeyArrowLeft: - v.MoveCursor(-1, 0, false) + textArea.MoveCursorLeft() case key == gocui.KeyArrowRight: - v.MoveCursor(1, 0, false) + textArea.MoveCursorRight() case key == newlineKey: - v.EditNewLine() + if allowMultiline { + textArea.TypeRune('\n') + } else { + return false + } case key == gocui.KeySpace: - v.EditWrite(' ') + textArea.TypeRune(' ') case key == gocui.KeyInsert: - v.Overwrite = !v.Overwrite + textArea.ToggleOverwrite() case key == gocui.KeyCtrlU: - v.EditDeleteToStartOfLine() + textArea.DeleteToStartOfLine() case key == gocui.KeyCtrlA: - v.EditGotoToStartOfLine() + textArea.GoToStartOfLine() case key == gocui.KeyCtrlE: - v.EditGotoToEndOfLine() + textArea.GoToEndOfLine() // TODO: see if we need all three of these conditions: maybe the final one is sufficient case ch != 0 && mod == 0 && unicode.IsPrint(ch): - v.EditWrite(ch) + textArea.TypeRune(ch) default: - matched = false + return false } + return true +} + +// we've just copy+pasted the editor from gocui to here so that we can also re- +// render the commit message length on each keypress +func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { + matched := gui.handleEditorKeypress(v.TextArea, key, ch, mod, true) + + // This function is called again on refresh as part of the general resize popup call, + // but we need to call it here so that when we go to render the text area it's not + // considered out of bounds to add a newline, meaning we can avoid unnecessary scrolling. + err := gui.resizePopupPanel(v, v.TextArea.GetContent()) + if err != nil { + gui.Log.Error(err) + } + v.RenderTextArea() gui.RenderCommitLength() return matched } func (gui *Gui) defaultEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { - matched := true - switch { - case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: - v.EditDelete(true) - case key == gocui.KeyCtrlD || 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.KeySpace: - v.EditWrite(' ') - case key == gocui.KeyInsert: - v.Overwrite = !v.Overwrite - case key == gocui.KeyCtrlU: - v.EditDeleteToStartOfLine() - case key == gocui.KeyCtrlA: - v.EditGotoToStartOfLine() - case key == gocui.KeyCtrlE: - v.EditGotoToEndOfLine() + matched := gui.handleEditorKeypress(v.TextArea, key, ch, mod, false) - // TODO: see if we need all three of these conditions: maybe the final one is sufficient - case ch != 0 && mod == 0 && unicode.IsPrint(ch): - v.EditWrite(ch) - default: - matched = false - } + v.RenderTextArea() if gui.findSuggestions != nil { - input := v.Buffer() + input := v.TextArea.GetContent() suggestions := gui.findSuggestions(input) gui.setSuggestions(suggestions) } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 28554a428..05b966e5d 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -347,9 +347,10 @@ func (gui *Gui) handleWIPCommitPress() error { ret |