Respect symlinks when tagging files (#1997)

This commit is contained in:
Joe Lim authored and GitHub committed 2025-05-30 15:15:30 +10:00
1 parent 7507be4d04
commit fe3a97c5d0
3 files changed
+12 -2

No files matched your search

+8
View File
@@ -31,6 +31,14 @@ func replaceTilde(s string) string {
return s return s
} }
func evalSymlinks(path string) string {
if target, err := filepath.EvalSymlinks(path); err == nil {
return target
}
return path
}
func runeSliceWidth(rs []rune) int { func runeSliceWidth(rs []rune) int {
w := 0 w := 0
for _, r := range rs { for _, r := range rs {
+3 -1
View File
@@ -1161,6 +1161,8 @@ func (nav *nav) toggle() {
} }
func (nav *nav) tagToggleSelection(path string, tag string) { func (nav *nav) tagToggleSelection(path string, tag string) {
path = evalSymlinks(path)
if _, ok := nav.tags[path]; ok { if _, ok := nav.tags[path]; ok {
delete(nav.tags, path) delete(nav.tags, path)
} else { } else {
@@ -1196,7 +1198,7 @@ func (nav *nav) tag(tag string) error {
} }
for _, path := range list { for _, path := range list {
nav.tags[path] = tag nav.tags[evalSymlinks(path)] = tag
} }
return nil return nil
+1 -1
View File
@@ -458,7 +458,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
} }
tag := " " tag := " "
if val, ok := context.tags[path]; ok && len(val) > 0 { if val, ok := context.tags[evalSymlinks(path)]; ok && len(val) > 0 {
tag = val tag = val
} }