From 147911a2899c9513cd49a205c6a07c418c4651c9 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Tue, 11 Nov 2025 12:06:39 -0300 Subject: [PATCH] Allow navigating excluded directories when shown --- yazi-actor/src/mgr/exclude_add.rs | 29 ++++++++++++++++++++++++++++- yazi-actor/src/mgr/ignore.rs | 21 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/yazi-actor/src/mgr/exclude_add.rs b/yazi-actor/src/mgr/exclude_add.rs index 089e630a..5a07ee5e 100644 --- a/yazi-actor/src/mgr/exclude_add.rs +++ b/yazi-actor/src/mgr/exclude_add.rs @@ -33,7 +33,7 @@ impl Actor for ExcludeAdd { // Check if the current folder itself is matched by any of the patterns // If so, don't apply the filter - we're viewing inside a gitignored directory - if let Some(_cwd_path) = cwd.as_path() { + if let Some(cwd_path) = cwd.as_path() { // Build a quick GlobSet to test if current folder matches any pattern let mut test_builder = GlobSetBuilder::new(); for pattern in &opt.patterns { @@ -44,6 +44,33 @@ impl Actor for ExcludeAdd { test_builder.add(glob); } } + + // Check if CWD matches any ignore pattern + if let Ok(test_set) = test_builder.build() { + // Test both absolute path and relative components + let mut matches_ignore = test_set.is_match(cwd_path); + + // Also check path components for patterns like "target" matching + // "/path/to/target" + if !matches_ignore { + if let Some(components) = cwd_path.to_str() { + for (i, _) in components.match_indices('/').skip(1) { + if let Some(subpath) = components.get(i + 1..) { + if test_set.is_match(subpath) { + matches_ignore = true; + break; + } + } + } + } + } + + // If we're inside an excluded directory, don't apply any filters + // This allows viewing the contents of gitignored directories + if matches_ignore { + succ!(); + } + } } // Get existing patterns from config diff --git a/yazi-actor/src/mgr/ignore.rs b/yazi-actor/src/mgr/ignore.rs index 03e4e990..047ba0d2 100644 --- a/yazi-actor/src/mgr/ignore.rs +++ b/yazi-actor/src/mgr/ignore.rs @@ -29,6 +29,27 @@ impl Actor for Ignore { let exclude_patterns = YAZI.files.excludes_for_context(&cwd_str); + // Check if we're inside an excluded directory + // If so, don't apply filters to allow viewing excluded directory contents + if let Some(cwd_path) = cwd.as_path() { + // Quick test: does the CWD match any exclude pattern? + for pattern in &exclude_patterns { + if pattern.starts_with('!') { + continue; // Skip negation patterns + } + + // Simple pattern matching for common cases like ".git", "target", etc. + if let Some(name) = cwd_path.file_name().and_then(|n| n.to_str()) { + // Remove glob wildcards for comparison + let clean_pattern = pattern.trim_end_matches("/**").trim_start_matches("**/"); + if name == clean_pattern || pattern == name { + // We're inside an excluded directory, skip applying filters + succ!(); + } + } + } + } + // Create glob matcher function for compiled patterns let glob_matcher: Option Option + Send + Sync>> = if !exclude_patterns.is_empty() {