diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-06-10 00:15:26 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-06-10 00:15:26 +0200 |
| commit | 219586ede723e7b2161d37169ff9c3e9831a7c66 (patch) | |
| tree | cdd72e5d75af71fd55961f676718cec6486c1a32 /internal/prompt/pwd.go | |
| parent | daeb9127764fc9dd469294f755e277fdfca09a00 (diff) | |
| download | gofu-219586ede723e7b2161d37169ff9c3e9831a7c66.tar.gz | |
run `go fix ./...`v2026.1
Diffstat (limited to 'internal/prompt/pwd.go')
| -rw-r--r-- | internal/prompt/pwd.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/internal/prompt/pwd.go b/internal/prompt/pwd.go index b549a39..e10da84 100644 --- a/internal/prompt/pwd.go +++ b/internal/prompt/pwd.go @@ -9,7 +9,7 @@ import ( "strings" ) -//Directory contains all data about a directory that the prompt needs. +// Directory contains all data about a directory that the prompt needs. type Directory struct { Path string DisplayPath string //formatted for display in prompt line @@ -20,8 +20,7 @@ type Directory struct { NearestAccessiblePath string } -//CurrentDirectory prepares a Directory struct for the current working -//directory. +// CurrentDirectory prepares a Directory struct for the current working directory. func CurrentDirectory() Directory { cwd, err := os.Getwd() if err != nil { @@ -30,7 +29,7 @@ func CurrentDirectory() Directory { return NewDirectory(cwd) } -//NewDirectory prepares a Directory struct for the given path. +// NewDirectory prepares a Directory struct for the given path. func NewDirectory(path string) (dir Directory) { dir.Path = path dir.DisplayPath = path @@ -82,7 +81,7 @@ func NewDirectory(path string) (dir Directory) { return } -//This part can benefit from a "return" in the middle, so it's in a separate function. +// This part can benefit from a "return" in the middle, so it's in a separate function. func (dir *Directory) stripHomeDirFromDisplay() { if !strings.HasPrefix(dir.DisplayPath, "/") { return @@ -129,8 +128,7 @@ func getDirectoryField(dir Directory, tt *TerminalTitle) string { //cwd accessible -> highlight path elements inside the repo (if any) if dir.Repo != nil && dir.Repo.RootPath != dir.Path { rel, _ := filepath.Rel(dir.Repo.RootPath, dir.Path) - if strings.HasSuffix(dir.DisplayPath, rel) { - base := strings.TrimSuffix(dir.DisplayPath, rel) + if base, ok := strings.CutSuffix(dir.DisplayPath, rel); ok { txt = withColor("0;36", base) + withColor("1;36", rel) } } |
