From 441bde1d976c2537385aaaa75546eb41ac1b0f37 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 26 Mar 2025 01:29:19 +0300 Subject: [PATCH] fix(ui): windows: always use path.Join instead of filepath.Join Git filesystem uses Unix path separators, so we should always use path.Join instead of filepath.Join to ensure that the paths are correctly formatted on Windows. --- pkg/ui/pages/repo/files.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/ui/pages/repo/files.go b/pkg/ui/pages/repo/files.go index fd43969fe7d07644542e105985a6081c18b34b58..6a1a1a8275b026a21dbedc6d0900c8cd3a505be0 100644 --- a/pkg/ui/pages/repo/files.go +++ b/pkg/ui/pages/repo/files.go @@ -3,7 +3,7 @@ package repo import ( "errors" "fmt" - "path/filepath" + "path" "strings" gitm "github.com/aymanbagabas/git-module" @@ -252,7 +252,7 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch sel := msg.IdentifiableItem.(type) { case FileItem: f.currentItem = &sel - f.path = filepath.Join(f.path, sel.entry.Name()) + f.path = path.Join(f.path, sel.entry.Name()) if sel.entry.IsTree() { cmds = append(cmds, f.selectTreeCmd) } else { @@ -457,19 +457,19 @@ func (f *Files) selectFileCmd() tea.Msg { if !bin { bin, err = fi.IsBinary() if err != nil { - f.path = filepath.Dir(f.path) + f.path = path.Dir(f.path) return common.ErrorMsg(err) } } if bin { - f.path = filepath.Dir(f.path) + f.path = path.Dir(f.path) return common.ErrorMsg(errBinaryFile) } c, err := fi.Bytes() if err != nil { - f.path = filepath.Dir(f.path) + f.path = path.Dir(f.path) return common.ErrorMsg(err) } @@ -526,7 +526,7 @@ func renderBlame(c common.Common, f *FileItem, b *gitm.Blame) string { } func (f *Files) deselectItemCmd() tea.Cmd { - f.path = filepath.Dir(f.path) + f.path = path.Dir(f.path) index := 0 if len(f.lastSelected) > 0 { index = f.lastSelected[len(f.lastSelected)-1]