@@ -61,7 +61,13 @@ pub fn display_tree(
6161 // Sort: directories first, then alphabetically
6262 entries. sort_by_key ( |e| {
6363 let path = e. path ( ) ;
64- let is_dir = path. is_dir ( ) ;
64+ // Check if it's a symlink pointing to a directory
65+ let is_dir = if path. is_symlink ( ) {
66+ // Don't follow symlinks to avoid infinite loops
67+ false
68+ } else {
69+ path. is_dir ( )
70+ } ;
6571 let name = e. file_name ( ) . to_string_lossy ( ) . to_lowercase ( ) ;
6672 ( !is_dir, name)
6773 } ) ;
@@ -72,7 +78,14 @@ pub fn display_tree(
7278 let is_last_entry = idx == total - 1 ;
7379 let path = entry. path ( ) ;
7480 let name = entry. file_name ( ) . to_string_lossy ( ) . to_string ( ) ;
75- let is_dir = path. is_dir ( ) ;
81+
82+ // Check if it's a symlink first - NEVER recurse into symlinks
83+ let is_symlink = path. is_symlink ( ) ;
84+ let is_dir = if is_symlink {
85+ false // Treat symlinks as files to prevent recursion
86+ } else {
87+ path. is_dir ( )
88+ } ;
7689
7790 // Check if we should skip this entry
7891 if is_dir {
@@ -90,6 +103,7 @@ pub fn display_tree(
90103 if should_skip {
91104 // Count files in ignored directory
92105 let ignored_count = WalkDir :: new ( & path)
106+ . follow_links ( false )
93107 . into_iter ( )
94108 . filter_map ( |e| e. ok ( ) )
95109 . filter ( |e| e. file_type ( ) . is_file ( ) )
@@ -145,7 +159,14 @@ pub fn display_tree(
145159
146160 // Display the entry
147161 let connector = if is_last_entry { "└── " } else { "├── " } ;
148- let display_name = if is_dir {
162+ let display_name = if is_symlink {
163+ // Show symlink with arrow
164+ if let Ok ( target) = fs:: read_link ( & path) {
165+ format ! ( "{} -> {}" , name, target. display( ) ) . cyan ( )
166+ } else {
167+ name. cyan ( )
168+ }
169+ } else if is_dir {
149170 format ! ( "{}/" , name) . blue ( ) . bold ( )
150171 } else if is_executable ( & path) {
151172 name. green ( ) . bold ( )
0 commit comments