display cwd in session list so right-click opens directory

This commit is contained in:
Levi Neely 2026-05-02 10:42:45 +02:00
parent 953ce987c0
commit ff9c517b23
1 changed files with 14 additions and 10 deletions

24
main.go
View File

@ -73,19 +73,23 @@ func (sl *sessionList) refresh() {
sl.mu.Lock()
sl.allSIDs = nil
for _, l := range lines {
if s := strings.TrimSpace(l); s != "" {
id, _, _ := strings.Cut(s, "\t")
sl.allSIDs = append(sl.allSIDs, id)
}
}
var buf strings.Builder
for _, sid := range sl.allSIDs {
parts := strings.Split(sid, "__")
for _, l := range lines {
s := strings.TrimSpace(l)
if s == "" {
continue
}
fields := strings.Split(s, "\t")
id := fields[0]
sl.allSIDs = append(sl.allSIDs, id)
parts := strings.Split(id, "__")
indent := strings.Repeat(" ", len(parts)-1)
leaf := parts[len(parts)-1]
fmt.Fprintf(&buf, "%s%s\n", indent, leaf)
cwd := ""
if len(fields) > 2 {
cwd = "\t" + fields[2]
}
fmt.Fprintf(&buf, "%s%s%s\n", indent, leaf, cwd)
}
sl.mu.Unlock()