mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-22 04:42:37 +03:00
Cleanup: put the IsPasting logic in the right place
Previously it was used both for the Confirm handler and the Cancel handler, as well as for the Confirm handler of confirmation popups (not prompts). There was no other way to do it given how wrappedConfirmationFunction was shared between all these; but now there is. The logic is really only needed for the Confirm handler of prompts. This doesn't fix anything, it just makes things clearer.
This commit is contained in:
@@ -25,14 +25,6 @@ func NewConfirmationHelper(c *HelperCommon) *ConfirmationHelper {
|
|||||||
// keybindings.
|
// keybindings.
|
||||||
|
|
||||||
func (self *ConfirmationHelper) closeAndCallConfirmationFunction(cancel goContext.CancelFunc, function func() error) error {
|
func (self *ConfirmationHelper) closeAndCallConfirmationFunction(cancel goContext.CancelFunc, function func() error) error {
|
||||||
if self.c.GocuiGui().IsPasting {
|
|
||||||
// The user is pasting multi-line text into a prompt; we don't want to handle the
|
|
||||||
// line feeds as "confirm" keybindings. Simply ignoring them is the best we can do; this
|
|
||||||
// will cause the entire pasted text to appear as a single line in the prompt. Hopefully
|
|
||||||
// the user knows that ctrl-u allows them to delete it again...
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
@@ -54,6 +46,14 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can
|
|||||||
|
|
||||||
func (self *ConfirmationHelper) wrappedPromptConfirmationFunction(cancel goContext.CancelFunc, function func(string) error, getResponse func() string) func() error {
|
func (self *ConfirmationHelper) wrappedPromptConfirmationFunction(cancel goContext.CancelFunc, function func(string) error, getResponse func() string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
|
if self.c.GocuiGui().IsPasting {
|
||||||
|
// The user is pasting multi-line text into a prompt; we don't want to handle the
|
||||||
|
// line feeds as "confirm" keybindings. Simply ignoring them is the best we can do; this
|
||||||
|
// will cause the entire pasted text to appear as a single line in the prompt. Hopefully
|
||||||
|
// the user knows that ctrl-u allows them to delete it again...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return self.closeAndCallConfirmationFunction(cancel, func() error {
|
return self.closeAndCallConfirmationFunction(cancel, func() error {
|
||||||
return function(getResponse())
|
return function(getResponse())
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user