@@ -48,19 +48,11 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
48
48
},
49
49
},
50
50
{
51
- Key : opts .GetKey (opts .Config .Universal .CopyToClipboard ),
52
- Handler : func () error {
53
- confirmationView := self .c .Views ().Confirmation
54
- text := confirmationView .Buffer ()
55
- if err := self .c .OS ().CopyToClipboard (text ); err != nil {
56
- return err
57
- }
58
-
59
- self .c .Toast (self .c .Tr .MessageCopiedToClipboard )
60
- return nil
61
- },
62
- Description : self .c .Tr .CopyToClipboardMenu ,
63
- DisplayOnScreen : true ,
51
+ Key : opts .GetKey (opts .Config .Universal .CopyToClipboard ),
52
+ Handler : self .handleCopyToClipboard ,
53
+ Description : self .c .Tr .CopyToClipboardMenu ,
54
+ DisplayOnScreen : true ,
55
+ GetDisabledReason : self .copyToClipboardEnabled ,
64
56
},
65
57
}
66
58
@@ -108,3 +100,23 @@ func (self *ConfirmationController) switchToSuggestions() {
108
100
self .c .Views ().Suggestions .Subtitle = subtitle
109
101
self .c .Context ().Replace (self .c .Contexts ().Suggestions )
110
102
}
103
+
104
+ func (self * ConfirmationController ) handleCopyToClipboard () error {
105
+ confirmationView := self .c .Views ().Confirmation
106
+ text := confirmationView .Buffer ()
107
+ if err := self .c .OS ().CopyToClipboard (text ); err != nil {
108
+ return err
109
+ }
110
+
111
+ self .c .Toast (self .c .Tr .MessageCopiedToClipboard )
112
+ return nil
113
+ }
114
+
115
+ func (self * ConfirmationController ) copyToClipboardEnabled () * types.DisabledReason {
116
+ if self .c .Views ().Confirmation .Editable {
117
+ // The empty text is intentional. We don't want to get a toast when invoking this, we only
118
+ // want to prevent it from showing up in the options bar.
119
+ return & types.DisabledReason {Text : "" }
120
+ }
121
+ return nil
122
+ }
0 commit comments