diff options
| author | Mantas Mikulėnas <grawity@gmail.com> | 2024-02-15 09:47:43 +0200 |
|---|---|---|
| committer | Mantas Mikulėnas <grawity@gmail.com> | 2024-02-15 09:52:15 +0200 |
| commit | 06a099298691641d86a3ab0c2194319d9363a919 (patch) | |
| tree | ca8501090c465d53c10ccbb3c5cf99be47a17f0a | |
| parent | e41670cde22959470f6b9ffef6e978e4f24d2cd5 (diff) | |
correctly gather path even if not shown
Otherwise it's missing the parent ghost entries:
[foo]
+- [bar]
+- [baz]
+- baz/asdf.png
| -rwxr-xr-x | treeify | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -142,21 +142,25 @@ sub show { $n_children = deepcount($node); } + # Display full path of the current node + my $fullname; + if ($path eq "") { + $fullname = $name; + } elsif ($path eq $opt{separator}) { + $fullname = $opt{reverse} + ? $name.$path + : $path.$name; + } elsif ($depth > $skip_path_levels) { + $fullname = $opt{reverse} + ? $name.$opt{separator}.$path + : $path.$opt{separator}.$name; + } + my $print_full = ($opt{print_full} == 2) ? $exists : ($opt{print_full} == 1) ? 1 : 0; - if ($print_full) { - # Display full path of the current node - if ($path eq $opt{separator}) { - $name = $opt{reverse} - ? $name.$path - : $path.$name; - } elsif ($depth > $skip_path_levels) { - $name = $opt{reverse} - ? $name.$opt{separator}.$path - : $path.$opt{separator}.$name; - } + $name = $fullname; } if ($depth > 0) { @@ -198,7 +202,7 @@ sub show { } print "$line_str\n"; - show($node, $seen, $depth+1, $graph, $name) if !$at_max_depth; + show($node, $seen, $depth+1, $graph, $fullname) if !$at_max_depth; } pop @$graph; |
