From ccf1b8517eced7df53dbcfed69e706eba25ebb6b Mon Sep 17 00:00:00 2001 From: lucaronin Date: Thu, 2 Apr 2026 17:39:55 +0200 Subject: [PATCH] fix: apply rustfmt formatting to vault scanner code Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/vault/mod.rs | 98 ++++++++++++++++++++++++++++---- src-tauri/src/vault/mod_tests.rs | 11 +++- 2 files changed, 96 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/vault/mod.rs b/src-tauri/src/vault/mod.rs index ad5fad3e..bbac8bab 100644 --- a/src-tauri/src/vault/mod.rs +++ b/src-tauri/src/vault/mod.rs @@ -126,7 +126,10 @@ pub fn parse_md_file(path: &Path, git_dates: Option<(u64, u64)>) -> Result) -> Result { +pub(crate) fn parse_non_md_file( + path: &Path, + git_dates: Option<(u64, u64)>, +) -> Result { let filename = path .file_name() .map(|f| f.to_string_lossy().to_string()) @@ -176,12 +179,71 @@ pub(crate) fn is_md_file(path: &Path) -> bool { /// Extensions recognized as editable text files (opened in raw editor). const TEXT_EXTENSIONS: &[&str] = &[ - "yml", "yaml", "json", "txt", "toml", "csv", "xml", "html", "htm", "css", "scss", "less", - "ts", "tsx", "js", "jsx", "py", "rs", "sh", "bash", "zsh", "fish", "rb", "go", "java", - "kt", "c", "cpp", "h", "hpp", "swift", "lua", "sql", "graphql", "env", "ini", "cfg", - "conf", "properties", "makefile", "dockerfile", "gitignore", "editorconfig", "mdx", - "svelte", "vue", "astro", "tf", "hcl", "nix", "zig", "hs", "ml", "ex", "exs", "erl", - "clj", "lisp", "el", "vim", "r", "jl", "ps1", "bat", "cmd", + "yml", + "yaml", + "json", + "txt", + "toml", + "csv", + "xml", + "html", + "htm", + "css", + "scss", + "less", + "ts", + "tsx", + "js", + "jsx", + "py", + "rs", + "sh", + "bash", + "zsh", + "fish", + "rb", + "go", + "java", + "kt", + "c", + "cpp", + "h", + "hpp", + "swift", + "lua", + "sql", + "graphql", + "env", + "ini", + "cfg", + "conf", + "properties", + "makefile", + "dockerfile", + "gitignore", + "editorconfig", + "mdx", + "svelte", + "vue", + "astro", + "tf", + "hcl", + "nix", + "zig", + "hs", + "ml", + "ex", + "exs", + "erl", + "clj", + "lisp", + "el", + "vim", + "r", + "jl", + "ps1", + "bat", + "cmd", ]; /// Classify a file extension into "markdown", "text", or "binary". @@ -190,10 +252,24 @@ pub(crate) fn classify_file_kind(path: &Path) -> &'static str { Some(e) => e.to_string_lossy().to_lowercase(), None => { // Files without extension: check if name itself is a known text file - let name = path.file_name().map(|n| n.to_string_lossy().to_lowercase()).unwrap_or_default(); - return if ["makefile", "dockerfile", "rakefile", "gemfile", "procfile", "brewfile", - ".gitignore", ".gitattributes", ".editorconfig", ".env"] - .contains(&name.as_str()) { + let name = path + .file_name() + .map(|n| n.to_string_lossy().to_lowercase()) + .unwrap_or_default(); + return if [ + "makefile", + "dockerfile", + "rakefile", + "gemfile", + "procfile", + "brewfile", + ".gitignore", + ".gitattributes", + ".editorconfig", + ".env", + ] + .contains(&name.as_str()) + { "text" } else { "binary" diff --git a/src-tauri/src/vault/mod_tests.rs b/src-tauri/src/vault/mod_tests.rs index 79744561..d31e2f51 100644 --- a/src-tauri/src/vault/mod_tests.rs +++ b/src-tauri/src/vault/mod_tests.rs @@ -133,7 +133,11 @@ fn test_scan_vault_root_and_protected_folders() { "---\ntype: Type\n---\n# Project\n", ); create_test_file(dir.path(), "attachments/notes.md", "# Attachment note\n"); - create_test_file(dir.path(), "not-markdown.txt", "This should be included as text"); + create_test_file( + dir.path(), + "not-markdown.txt", + "This should be included as text", + ); let entries = scan_vault(dir.path(), &HashMap::new()).unwrap(); assert_eq!(entries.len(), 4); @@ -144,7 +148,10 @@ fn test_scan_vault_root_and_protected_folders() { assert!(filenames.contains(&"notes.md")); assert!(filenames.contains(&"not-markdown.txt")); - let txt_entry = entries.iter().find(|e| e.filename == "not-markdown.txt").unwrap(); + let txt_entry = entries + .iter() + .find(|e| e.filename == "not-markdown.txt") + .unwrap(); assert_eq!(txt_entry.file_kind, "text"); assert_eq!(txt_entry.title, "not-markdown.txt"); }