File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,13 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
47
47
return nil
48
48
},
49
49
},
50
+ {
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 ,
56
+ },
50
57
}
51
58
52
59
return bindings
@@ -93,3 +100,23 @@ func (self *ConfirmationController) switchToSuggestions() {
93
100
self .c .Views ().Suggestions .Subtitle = subtitle
94
101
self .c .Context ().Replace (self .c .Contexts ().Suggestions )
95
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
+ }
Original file line number Diff line number Diff line change @@ -723,6 +723,7 @@ type TranslationSet struct {
723
723
CommitHasNoTags string
724
724
CommitHasNoMessageBody string
725
725
PatchCopiedToClipboard string
726
+ MessageCopiedToClipboard string
726
727
CopiedToClipboard string
727
728
ErrCannotEditDirectory string
728
729
ErrCannotCopyContentOfDirectory string
@@ -1800,6 +1801,7 @@ func EnglishTranslationSet() *TranslationSet {
1800
1801
CommitHasNoTags : "Commit has no tags" ,
1801
1802
CommitHasNoMessageBody : "Commit has no message body" ,
1802
1803
PatchCopiedToClipboard : "Patch copied to clipboard" ,
1804
+ MessageCopiedToClipboard : "Message copied to clipboard" ,
1803
1805
CopiedToClipboard : "copied to clipboard" ,
1804
1806
ErrCannotEditDirectory : "Cannot edit directories: you can only edit individual files" ,
1805
1807
ErrCannotCopyContentOfDirectory : "Cannot copy content of directories: you can only copy content of individual files" ,
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ func (self *Popup) Alert() *AlertDriver {
36
36
return & AlertDriver {t : self .t }
37
37
}
38
38
39
+ func (self * AlertDriver ) Tap (f func ()) * AlertDriver {
40
+ self .getViewDriver ().Tap (f )
41
+ return self
42
+ }
43
+
39
44
func (self * Popup ) inAlert () {
40
45
// basically the same thing as a confirmation popup with the current implementation
41
46
self .t .assertWithRetries (func () (bool , string ) {
Original file line number Diff line number Diff line change
1
+ package misc
2
+
3
+ import (
4
+ "github.com/jesseduffield/lazygit/pkg/config"
5
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
6
+ )
7
+
8
+ var CopyConfirmationMessageToClipboard = NewIntegrationTest (NewIntegrationTestArgs {
9
+ Description : "Copy the text of a confirmation popup to the clipboard" ,
10
+ ExtraCmdArgs : []string {},
11
+ Skip : false ,
12
+ SetupConfig : func (config * config.AppConfig ) {
13
+ config .GetUserConfig ().OS .CopyToClipboardCmd = "printf '%s' {{text}} > clipboard"
14
+ },
15
+
16
+ SetupRepo : func (shell * Shell ) {
17
+ shell .EmptyCommit ("commit" )
18
+ },
19
+
20
+ Run : func (t * TestDriver , keys config.KeybindingConfig ) {
21
+ t .Views ().Commits ().
22
+ Focus ().
23
+ Lines (
24
+ Contains ("commit" ).IsSelected (),
25
+ ).
26
+ Press (keys .Universal .Remove )
27
+
28
+ t .ExpectPopup ().Alert ().
29
+ Title (Equals ("Drop commit" )).
30
+ Content (Equals ("Are you sure you want to drop the selected commit(s)?" )).
31
+ Tap (func () {
32
+ t .GlobalPress (keys .Universal .CopyToClipboard )
33
+ t .ExpectToast (Equals ("Message copied to clipboard" ))
34
+ }).
35
+ Confirm ()
36
+
37
+ t .FileSystem ().FileContent ("clipboard" ,
38
+ Equals ("Are you sure you want to drop the selected commit(s)?" ))
39
+ },
40
+ })
Original file line number Diff line number Diff line change @@ -299,6 +299,7 @@ var tests = []*components.IntegrationTest{
299
299
interactive_rebase .SwapWithConflict ,
300
300
interactive_rebase .ViewFilesOfTodoEntries ,
301
301
misc .ConfirmOnQuit ,
302
+ misc .CopyConfirmationMessageToClipboard ,
302
303
misc .CopyToClipboard ,
303
304
misc .DisabledKeybindings ,
304
305
misc .InitialOpen ,
You can’t perform that action at this time.
0 commit comments