on main help sign in
fix(sidebar): fix full path appearing on sidebar on windows
dba44beAndrey Nering
internal/tui/components/files/files.go+4−1
@@ -3,6 +3,7 @@ package files
3import (
3import (
4 "fmt"
4 "fmt"
5 "os"
5 "os"
6+ "path/filepath"
6 "sort"
7 "sort"
7 "strings"
8 "strings"
8
9
@@ -91,7 +92,9 @@ func RenderFileList(fileSlice []SessionFile, opts RenderOptions) []string {
91 extraContent := strings.Join(statusParts, " ")
92 extraContent := strings.Join(statusParts, " ")
92 cwd := config.Get().WorkingDir() + string(os.PathSeparator)
93 cwd := config.Get().WorkingDir() + string(os.PathSeparator)
93 filePath := file.FilePath
94 filePath := file.FilePath
94− filePath = strings.TrimPrefix(filePath, cwd)
95+ if rel, err := filepath.Rel(cwd, filePath); err == nil {
96+ filePath = rel
97+ }
95 filePath = fsext.DirTrim(fsext.PrettyPath(filePath), 2)
98 filePath = fsext.DirTrim(fsext.PrettyPath(filePath), 2)
96 filePath = ansi.Truncate(filePath, opts.MaxWidth-lipgloss.Width(extraContent)-2, "…")
99 filePath = ansi.Truncate(filePath, opts.MaxWidth-lipgloss.Width(extraContent)-2, "…")
97
100