mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-25 18:55:28 -06:00
Merge pull request #2373 from phanithinks/clipboard_patch_option_2357
This commit is contained in:
@@ -69,6 +69,14 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
}
|
||||
}
|
||||
|
||||
menuItems = append(menuItems, []*types.MenuItem{
|
||||
{
|
||||
Label: "copy patch to clipboard",
|
||||
OnPress: func() error { return gui.copyPatchToClipboard() },
|
||||
Key: 'y',
|
||||
},
|
||||
}...)
|
||||
|
||||
return gui.c.Menu(types.CreateMenuOptions{Title: gui.c.Tr.PatchOptionsTitle, Items: menuItems})
|
||||
}
|
||||
|
||||
@@ -192,3 +200,16 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
|
||||
}
|
||||
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
}
|
||||
|
||||
func (gui *Gui) copyPatchToClipboard() error {
|
||||
patch := gui.git.Patch.PatchManager.RenderAggregatedPatchColored(true)
|
||||
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CopyPatchToClipboard)
|
||||
if err := gui.os.CopyToClipboard(patch); err != nil {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
|
||||
gui.c.Toast(gui.c.Tr.PatchCopiedToClipboard)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user