Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
|-----|--------|-------------|
| `` <enter> `` | Confirm | |
| `` <esc> `` | Close/Cancel | |
| `` <c-o> `` | Copy to clipboard | |

## Files

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,4 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
|-----|--------|-------------|
| `` <enter> `` | 確認 | |
| `` <esc> `` | 閉じる/キャンセル | |
| `` <c-o> `` | クリップボードにコピー | |
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,4 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
|-----|--------|-------------|
| `` <enter> `` | 확인 | |
| `` <esc> `` | 닫기/취소 | |
| `` <c-o> `` | 클립보드에 복사 | |
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
|-----|--------|-------------|
| `` <enter> `` | Bevestig | |
| `` <esc> `` | Sluiten | |
| `` <c-o> `` | Copy to clipboard | |

## Branches

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
|-----|--------|-------------|
| `` <enter> `` | Potwierdź | |
| `` <esc> `` | Zamknij/Anuluj | |
| `` <c-o> `` | Kopiuj do schowka | |

## Pliki

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
|-----|--------|-------------|
| `` <enter> `` | Confirmar | |
| `` <esc> `` | Fechar/Cancelar | |
| `` <c-o> `` | Copy to clipboard | |

## Etiquetas

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ _Связки клавиш_
|-----|--------|-------------|
| `` <enter> `` | Подтвердить | |
| `` <esc> `` | Закрыть/отменить | |
| `` <c-o> `` | Copy to clipboard | |

## Подкоммиты

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
|-----|--------|-------------|
| `` <enter> `` | 确认 | |
| `` <esc> `` | 关闭 | |
| `` <c-o> `` | 复制到剪贴板 | |

## 菜单

Expand Down
1 change: 1 addition & 0 deletions docs/keybindings/Keybindings_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
|-----|--------|-------------|
| `` <enter> `` | 確認 | |
| `` <esc> `` | 關閉/取消 | |
| `` <c-o> `` | 複製到剪貼簿 | |

## 遠端

Expand Down
27 changes: 27 additions & 0 deletions pkg/gui/controllers/confirmation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
return nil
},
},
{
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopyToClipboard,
Description: self.c.Tr.CopyToClipboardMenu,
DisplayOnScreen: true,
GetDisabledReason: self.copyToClipboardEnabled,
},
}

return bindings
Expand Down Expand Up @@ -93,3 +100,23 @@ func (self *ConfirmationController) switchToSuggestions() {
self.c.Views().Suggestions.Subtitle = subtitle
self.c.Context().Replace(self.c.Contexts().Suggestions)
}

func (self *ConfirmationController) handleCopyToClipboard() error {
confirmationView := self.c.Views().Confirmation
text := confirmationView.Buffer()
if err := self.c.OS().CopyToClipboard(text); err != nil {
return err
}

self.c.Toast(self.c.Tr.MessageCopiedToClipboard)
return nil
}

func (self *ConfirmationController) copyToClipboardEnabled() *types.DisabledReason {
if self.c.Views().Confirmation.Editable {
// The empty text is intentional. We don't want to get a toast when invoking this, we only
// want to prevent it from showing up in the options bar.
return &types.DisabledReason{Text: ""}
}
return nil
}
2 changes: 2 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ type TranslationSet struct {
CommitHasNoTags string
CommitHasNoMessageBody string
PatchCopiedToClipboard string
MessageCopiedToClipboard string
CopiedToClipboard string
ErrCannotEditDirectory string
ErrCannotCopyContentOfDirectory string
Expand Down Expand Up @@ -1800,6 +1801,7 @@ func EnglishTranslationSet() *TranslationSet {
CommitHasNoTags: "Commit has no tags",
CommitHasNoMessageBody: "Commit has no message body",
PatchCopiedToClipboard: "Patch copied to clipboard",
MessageCopiedToClipboard: "Message copied to clipboard",
CopiedToClipboard: "copied to clipboard",
ErrCannotEditDirectory: "Cannot edit directories: you can only edit individual files",
ErrCannotCopyContentOfDirectory: "Cannot copy content of directories: you can only copy content of individual files",
Expand Down
5 changes: 5 additions & 0 deletions pkg/integration/components/popup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (self *Popup) Alert() *AlertDriver {
return &AlertDriver{t: self.t}
}

func (self *AlertDriver) Tap(f func()) *AlertDriver {
self.getViewDriver().Tap(f)
return self
}

func (self *Popup) inAlert() {
// basically the same thing as a confirmation popup with the current implementation
self.t.assertWithRetries(func() (bool, string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package misc

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var CopyConfirmationMessageToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Copy the text of a confirmation popup to the clipboard",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard"
},

SetupRepo: func(shell *Shell) {
shell.EmptyCommit("commit")
},

Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit").IsSelected(),
).
Press(keys.Universal.Remove)

t.ExpectPopup().Alert().
Title(Equals("Drop commit")).
Content(Equals("Are you sure you want to drop the selected commit(s)?")).
Tap(func() {
t.GlobalPress(keys.Universal.CopyToClipboard)
t.ExpectToast(Equals("Message copied to clipboard"))
}).
Confirm()

t.FileSystem().FileContent("clipboard",
Equals("Are you sure you want to drop the selected commit(s)?"))
},
})
5 changes: 0 additions & 5 deletions pkg/integration/tests/misc/copy_to_clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{

t.ExpectToast(Equals("'branch-a' copied to clipboard"))

t.Views().Files().
Focus()

t.GlobalPress(keys.Files.RefreshFiles)

t.FileSystem().FileContent("clipboard", Equals("branch-a"))
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ var tests = []*components.IntegrationTest{
interactive_rebase.SwapWithConflict,
interactive_rebase.ViewFilesOfTodoEntries,
misc.ConfirmOnQuit,
misc.CopyConfirmationMessageToClipboard,
misc.CopyToClipboard,
misc.DisabledKeybindings,
misc.InitialOpen,
Expand Down
Loading