mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Add a "Content of selected file" entry to the copy menu for commit files
This is useful for copying the entire content of the selected file as it was at the selected commit. We only add it to the commit files panel; it is not needed in the files panel, because there you can simply press "e" to edit the file.
This commit is contained in:
@ -23,17 +23,21 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFileAndAdd("dir/file1", "1st line\n")
|
||||
shell.Commit("1")
|
||||
shell.CreateFileAndAdd("dir/file1", "1st line\n2nd line\n")
|
||||
shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n")
|
||||
shell.CreateFileAndAdd("dir/file2", "file2\n")
|
||||
shell.Commit("2")
|
||||
shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n3rd line\n")
|
||||
shell.Commit("3")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("2").IsSelected(),
|
||||
Contains("3").IsSelected(),
|
||||
Contains("2"),
|
||||
Contains("1"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
@ -91,11 +95,22 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("diff --git a/dir/file1 b/dir/file1").Contains("+2nd line").DoesNotContain("+1st line").
|
||||
Contains("diff --git a/dir/file2 b/dir/file2").Contains("+file2"))
|
||||
})
|
||||
}).
|
||||
Press(keys.Files.CopyFileInfoToClipboard).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Copy to clipboard")).
|
||||
Select(Contains("Content of selected file")).
|
||||
Confirm().
|
||||
Tap(func() {
|
||||
t.ExpectToast(Equals("File content copied to clipboard"))
|
||||
expectClipboard(t, Equals("1st line\n2nd line\n"))
|
||||
})
|
||||
})
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
// Select both commits
|
||||
// Select commits 1 and 2
|
||||
Press(keys.Universal.RangeSelectDown).
|
||||
PressEnter()
|
||||
|
||||
@ -118,6 +133,17 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
expectClipboard(t,
|
||||
Contains("diff --git a/dir/file1 b/dir/file1").Contains("+1st line").Contains("+2nd line"))
|
||||
})
|
||||
}).
|
||||
Press(keys.Files.CopyFileInfoToClipboard).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Copy to clipboard")).
|
||||
Select(Contains("Content of selected file")).
|
||||
Confirm().
|
||||
Tap(func() {
|
||||
t.ExpectToast(Equals("File content copied to clipboard"))
|
||||
expectClipboard(t, Equals("1st line\n2nd line\n"))
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user