Skip to content

Commit 4833014

Browse files
committed
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.
1 parent 8d8cf42 commit 4833014

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/gui/controllers/helpers/confirmation_helper.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ func NewConfirmationHelper(c *HelperCommon) *ConfirmationHelper {
2525
// keybindings.
2626

2727
func (self *ConfirmationHelper) closeAndCallConfirmationFunction(cancel goContext.CancelFunc, function func() error) error {
28-
if self.c.GocuiGui().IsPasting {
29-
// The user is pasting multi-line text into a prompt; we don't want to handle the
30-
// line feeds as "confirm" keybindings. Simply ignoring them is the best we can do; this
31-
// will cause the entire pasted text to appear as a single line in the prompt. Hopefully
32-
// the user knows that ctrl-u allows them to delete it again...
33-
return nil
34-
}
35-
3628
cancel()
3729

3830
self.c.Context().Pop()
@@ -54,6 +46,14 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can
5446

5547
func (self *ConfirmationHelper) wrappedPromptConfirmationFunction(cancel goContext.CancelFunc, function func(string) error, getResponse func() string) func() error {
5648
return func() error {
49+
if self.c.GocuiGui().IsPasting {
50+
// The user is pasting multi-line text into a prompt; we don't want to handle the
51+
// line feeds as "confirm" keybindings. Simply ignoring them is the best we can do; this
52+
// will cause the entire pasted text to appear as a single line in the prompt. Hopefully
53+
// the user knows that ctrl-u allows them to delete it again...
54+
return nil
55+
}
56+
5757
return self.closeAndCallConfirmationFunction(cancel, func() error {
5858
return function(getResponse())
5959
})

0 commit comments

Comments
 (0)