mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Fix copying a file's absolute path when running in a linked worktree
This commit is contained in:
parent
94d6fce3cc
commit
d3095f6fd4
|
|
@ -248,7 +248,11 @@ func (self *CommitFilesController) openCopyMenu() error {
|
|||
copyAbsolutePathItem := &types.MenuItem{
|
||||
Label: self.c.Tr.CopyAbsoluteFilePath,
|
||||
OnPress: func() error {
|
||||
if err := self.c.OS().CopyToClipboard(filepath.Join(self.c.Git().RepoPaths.RepoPath(), node.GetPath())); err != nil {
|
||||
absPath, err := filepath.Abs(node.GetPath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := self.c.OS().CopyToClipboard(absPath); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.FilePathCopiedToast)
|
||||
|
|
|
|||
|
|
@ -1199,7 +1199,11 @@ func (self *FilesController) openCopyMenu() error {
|
|||
copyAbsolutePathItem := &types.MenuItem{
|
||||
Label: self.c.Tr.CopyAbsoluteFilePath,
|
||||
OnPress: func() error {
|
||||
if err := self.c.OS().CopyToClipboard(filepath.Join(self.c.Git().RepoPaths.RepoPath(), node.GetPath())); err != nil {
|
||||
absPath, err := filepath.Abs(node.GetPath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := self.c.OS().CopyToClipboard(absPath); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.FilePathCopiedToast)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package diff
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
|
|
@ -90,10 +89,7 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
t.ExpectToast(Equals("File path copied to clipboard"))
|
||||
worktreeDir, _ := os.Getwd()
|
||||
// On windows the following path would have backslashes, but we don't run integration tests on windows yet.
|
||||
/* EXPECTED:
|
||||
expectClipboard(t, Equals(worktreeDir+"/dir/file1"))
|
||||
ACTUAL: */
|
||||
expectClipboard(t, Equals(filepath.Dir(worktreeDir)+"/repo/dir/file1"))
|
||||
})
|
||||
}).
|
||||
Press(keys.Files.CopyFileInfoToClipboard).
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package file
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
|
|
@ -139,10 +138,7 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
|
||||
worktreeDir, _ := os.Getwd()
|
||||
// On windows the following path would have backslashes, but we don't run integration tests on windows yet.
|
||||
/* EXPECTED:
|
||||
expectClipboard(t, Equals(worktreeDir+"/dir/1-unstaged_file"))
|
||||
ACTUAL: */
|
||||
expectClipboard(t, Equals(filepath.Dir(worktreeDir)+"/repo/dir/1-unstaged_file"))
|
||||
})
|
||||
|
||||
// Selected path diff on a single (unstaged) file
|
||||
|
|
|
|||
Loading…
Reference in a new issue