mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-23 00:24:17 +02:00
fix: show symlinked files under their own name instead of target's name
stripAbsolutePath called filepath.EvalSymlinks on the full path, which resolved symlinks and caused symlinked files to display under their target's name. For example, AGENTS.md -> CLAUDE.md would appear as two CLAUDE.md entries in the document list. Use the original path for display while still resolving cwd symlinks. Fixes #965
This commit is contained in:
parent
53788271b3
commit
9085b2e0bc
1 changed files with 5 additions and 1 deletions
6
ui/ui.go
6
ui/ui.go
|
|
@ -432,7 +432,11 @@ func localFileToMarkdown(cwd string, res gitcha.SearchResult) *markdown {
|
|||
}
|
||||
|
||||
func stripAbsolutePath(fullPath, cwd string) string {
|
||||
fp, _ := filepath.EvalSymlinks(fullPath)
|
||||
// Don't resolve symlinks on fullPath — use the original path so that
|
||||
// symlinked files display under their own name (e.g. AGENTS.md) instead
|
||||
// of their target's name (e.g. CLAUDE.md).
|
||||
// We still resolve cwd in case the working directory itself is a symlink.
|
||||
fp := fullPath
|
||||
cp, _ := filepath.EvalSymlinks(cwd)
|
||||
return strings.ReplaceAll(fp, cp+string(os.PathSeparator), "")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue