From b2c306d69f9faa9c000cfa0919d51655ac120c44 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Wed, 7 Oct 2026 21:03:49 +0200 Subject: [PATCH] fix: scan vaults whose own folder name starts with a dot A vault kept in a dot-named folder such as ~/.notes was treated as hidden by seven vault walkers, so All Notes, note titles for links, Graph View, Tasks and rename link updates found no notes. Exempt the vault root from the hidden-folder check, as the tag scan and search already do. Hidden subfolders, .helixnotes and the existing hidden-name rules are unchanged. --- src-tauri/src/commands.rs | 45 ++++++++++++++++++++-- src-tauri/src/vault/operations.rs | 62 +++++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 0a82e29..536140d 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1026,7 +1026,9 @@ fn scan_all_note_titles(vault_path: &str) -> Result, String> .into_iter() // Cross-platform exclusion (string "/.helixnotes/" checks miss Windows // backslash paths, which leaked .helixnotes/history snapshots in as dupes). - .filter_entry(|e| !operations::is_hidden(e.path()) && !e.path().starts_with(&hn_dir)) + .filter_entry(|e| { + e.depth() == 0 || (!operations::is_hidden(e.path()) && !e.path().starts_with(&hn_dir)) + }) .filter_map(|e| e.ok()) .filter(|e| { e.path().is_file() && e.path().extension().and_then(|x| x.to_str()) == Some("md") @@ -1134,7 +1136,9 @@ fn scan_graph_data(vault_path: &str) -> Result // Windows backslash paths; is_hidden also covers .stversions/.stfolder/.trash/.git). let candidates: Vec = walkdir::WalkDir::new(vault) .into_iter() - .filter_entry(|e| !operations::is_hidden(e.path()) && !e.path().starts_with(&hn_dir)) + .filter_entry(|e| { + e.depth() == 0 || (!operations::is_hidden(e.path()) && !e.path().starts_with(&hn_dir)) + }) .filter_map(|e| e.ok()) .filter(|entry| { let path = entry.path(); @@ -1335,7 +1339,8 @@ fn scan_tasks(vault_path: &str, note_path: Option<&str>) -> Result let paths: Vec = walkdir::WalkDir::new(vault) .into_iter() .filter_entry(|entry| { - !operations::is_hidden(entry.path()) && !entry.path().starts_with(&hn_dir) + entry.depth() == 0 + || (!operations::is_hidden(entry.path()) && !entry.path().starts_with(&hn_dir)) }) .filter_map(|entry| entry.ok()) .filter(|entry| { @@ -1520,6 +1525,40 @@ mod graph_scan_tests { } } +#[cfg(test)] +mod dot_named_vault_tests { + use super::{scan_all_note_titles, scan_graph_data, scan_tasks}; + use std::fs; + + #[test] + fn vault_scans_do_not_treat_a_dot_named_vault_folder_as_hidden() { + // tempdir() names its folder ".tmpXXXX", like a vault kept in ~/.notes. + let vault = tempfile::tempdir().unwrap(); + assert!(vault + .path() + .file_name() + .unwrap() + .to_string_lossy() + .starts_with('.')); + let vault_path = vault.path().to_str().unwrap(); + fs::write( + vault.path().join("A.md"), + "---\ntitle: Alpha\n---\n[[Beta]]\n- [ ] Task\n", + ) + .unwrap(); + fs::write( + vault.path().join("B.md"), + "---\ntitle: Beta\n---\n[[Alpha]]\n", + ) + .unwrap(); + + assert_eq!(scan_all_note_titles(vault_path).unwrap().len(), 2); + let graph = scan_graph_data(vault_path).unwrap(); + assert_eq!((graph.nodes.len(), graph.edges.len()), (2, 1)); + assert_eq!(scan_tasks(vault_path, None).unwrap().len(), 1); + } +} + #[cfg(test)] mod task_tests { use super::scan_tasks; diff --git a/src-tauri/src/vault/operations.rs b/src-tauri/src/vault/operations.rs index ac0d175..2a20312 100644 --- a/src-tauri/src/vault/operations.rs +++ b/src-tauri/src/vault/operations.rs @@ -549,7 +549,9 @@ pub fn scan_notes(vault_path: &str, notebook_path: Option<&str>) -> Result