Skip to content

Commit 1c87776

Browse files
authored
When pasting multi-line text into a prompt, don't treat the line feeds as "confirm" (#4955)
This is likely to do bad things; for example, if the prompt is the shell command prompt, then we would run into what looks like a deadlock bug in tcell. In other cases, the characters in the following lines might be treated as random keybindings after the prompt is confirmed; this is very similar to #4234. In this case, it seems the best we can do is to simply swallow the line feeds. The entire pasted text will then appear as a single long line in the prompt, and hopefully the user knows that they can use ctrl-u to delete it again. If not, they will probably just hit esc to close the prompt. Fixes #4954.
2 parents 6b5b493 + fbaea58 commit 1c87776

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/gui/controllers/helpers/confirmation_helper.go

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

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

3139
self.c.Context().Pop()

0 commit comments

Comments
 (0)