Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(explorer): hide files.exclude and .gitignore matches in the tree (#109)

Artur Rokc1a47b00e5a6
diff --git a/native/crates/app/src/explorer.rs b/native/crates/app/src/explorer.rs
index ed0f24621af..eb09c44578c 100644
--- a/native/crates/app/src/explorer.rs
+++ b/native/crates/app/src/explorer.rs
@@ -1,6 +1,7 @@
//! The Explorer's file tree: which folders are expanded, and the visible rows read from disk in the
//! order the reference explorer sorts them (explorerViewer.ts `FileSorter` with the `explorer.sortOrder` settings).
+mod files_filter;
mod nesting;
use std::cell::RefCell;
@@ -16,6 +17,7 @@ use config::workspace::Workspace;
use serde_json::{Value, json};
use crate::editor::uri_string;
+use files_filter::{FilesFilter, FilterKey};
use nesting::FileNestingTrie;
use icu_collator::options::{CollatorOptions, Strength};
use icu_collator::preferences::CollationNumericOrdering;
@@ -59,6 +61,7 @@ struct EntriesKey {
mtime: SystemTime,
sorter: FileSorter,
nesting: [Value; 2],
+ filter: FilterKey,
}
struct Filter {
@@ -622,22 +625,26 @@ impl FileTree {
SystemTime::now().duration_since(*mtime).is_ok_and(|age| age >= racy)
});
let cacheable = sorter.order != "modified" && self.new_item.as_ref().is_none_or(|item| item.parent != folder);
- let Some(mtime) = settled.filter(|_| cacheable) else { return self.read_entries(folder, sorter) };
+ let filter = self.filter_key(folder);
+ let Some(mtime) = settled.filter(|_| cacheable) else { return self.read_entries(folder, sorter, &filter) };
let nesting = ["explorer.fileNesting.enabled", "explorer.fileNesting.patterns"].map(|key| self.nesting_setting(folder, key));
- let key = EntriesKey { mtime, sorter, nesting };
+ let key = EntriesKey { mtime, sorter, nesting, filter };
if let Some((cached, entries)) = self.entries_cache.borrow().get(folder)
&& *cached == key
{
return entries.clone();
}
- let entries = self.read_entries(folder, key.sorter.clone());
+ let entries = self.read_entries(folder, key.sorter.clone(), &key.filter);
self.entries_cache.borrow_mut().insert(folder.to_path_buf(), (key, entries.clone()));
entries
}
- fn read_entries(&self, folder: &Path, sorter: FileSorter) -> Vec<Entry> {
+ fn read_entries(&self, folder: &Path, sorter: FileSorter, filter: &FilterKey) -> Vec<Entry> {
let children = read_children(folder);
- let visible = |name: &str| !EXCLUDED_NAMES.contains(&name);
+ let filter = FilesFilter::new(filter);
+ let folder_excluded = filter.is_folder_excluded(folder);
+ let has_sibling = |name: &str| children.iter().any(|child| child.name == name);
+ let visible = |child: &Child| filter.is_visible(&child.path, child.is_dir, folder_excluded, &has_sibling);
// `files.exclude` filters the tree after nesting, so an excluded file still nests the files under it.
let nests = self.nester(folder).map(|nester| {
let files: Vec<String> = children.iter().filter(|child| !child.is_dir).map(|child| child.name.to_lowercase()).collect();
@@ -654,7 +661,7 @@ impl FileTree {
};
let mut entries = Vec::new();
for child in &children {
- if !visible(&child.name) {
+ if !visible(child) {
continue;
}
let mut nested = Vec::new();
@@ -662,7 +669,7 @@ impl FileTree {
&& !child.is_dir
{
let Some(nested_names) = nests.get(&child.name.to_lowercase()) else { continue };
- nested = children.iter().filter(|other| !other.is_dir && visible(&other.name) && nested_names.contains(&other.name.to_lowercase())).cloned().collect();
+ nested = children.iter().filter(|other| !other.is_dir && visible(other) && nested_names.contains(&other.name.to_lowercase())).cloned().collect();
nested.sort_by(|a, b| sorter.compare(a, false, b, false));
}
entries.push(Entry { child: child.clone(), nested, is_new: false });
@@ -675,6 +682,13 @@ impl FileTree {
entries
}
+ /// `files.exclude` and `explorer.excludeGitIgnore` of the folder's workspace root (`FilesFilter.updateConfiguration`).
+ fn filter_key(&self, folder: &Path) -> FilterKey {
+ let root = self.workspace.folders.iter().map(|root| &root.path).filter(|root| folder.starts_with(root)).max_by_key(|root| root.as_os_str().len()).expect("an Explorer folder is under a root");
+ let setting = |key| self.nesting_setting(root, key);
+ FilterKey::new(root, folder, setting("files.exclude"), setting("explorer.excludeGitIgnore") == json!(true))
+ }
+
fn file_sorter(&self) -> FileSorter {
let settings = self.settings.lock().unwrap();
let setting = |key| settings.get_value(Some(key), &Overrides::default()).unwrap_or(Value::Null);
@@ -1124,6 +1138,40 @@ mod tests {
std::fs::remove_dir_all(user).unwrap();
}
+ /// explorerFilesFilter.test.ts: exclude exceptions show their folders, and `.gitignore` hides what no exception shows.
+ #[test]
+ fn hides_files_exclude_and_gitignore_matches_but_not_exceptions() {
+ let root = std::env::temp_dir().join(format!("explorer-filter-test-{}", std::process::id()));
+ for dir in ["build", "out", "src", "node_modules/@types", "node_modules/react"] {
+ std::fs::create_dir_all(root.join(dir)).unwrap();
+ }
+ for file in ["build/keep.txt", "build/other.txt", "out/a.txt", "node_modules/@types/index.d.ts", "a.log", "gulpfile.js", "index.js"] {
+ std::fs::write(root.join(file), "").unwrap();
+ }
+ std::fs::write(root.join(".gitignore"), "build/\nout/\n*.log\n").unwrap();
+ let user = root.with_extension("user");
+ std::fs::create_dir_all(&user).unwrap();
+ let settings = Arc::new(Mutex::new(Settings::load(config::registry::Registry::with_extensions(&[]), user.clone(), None)));
+ let exclude = json!({ "node_modules": true, "*.js": true, "!node_modules/@types": true, "!gulpfile.js": true, "!build/keep.txt": true });
+ settings.lock().unwrap().update_value_derived("files.exclude", Some(&exclude)).unwrap();
+ let mut tree = FileTree::new(Workspace::folder(root.clone()), settings.clone());
+ for folder in ["build", "node_modules", "node_modules/@types"] {
+ tree.expand(&root.join(folder));
+ }
+ let shown = |tree: &FileTree| names(tree).into_iter().map(|(name, _)| name).collect::<Vec<_>>();
+ assert_eq!(shown(&tree), ["build", "keep.txt", "other.txt", "node_modules", "@types", "index.d.ts", "out", "src", ".gitignore", "a.log", "gulpfile.js"]);
+
+ settings.lock().unwrap().update_value_derived("explorer.excludeGitIgnore", Some(&json!(true))).unwrap();
+ assert_eq!(shown(&tree), ["build", "keep.txt", "node_modules", "@types", "index.d.ts", "src", ".gitignore", "gulpfile.js"], "build leads to an exception");
+
+ std::fs::write(root.join("src/.gitignore"), "!*.log\n").unwrap();
+ std::fs::write(root.join("src/b.log"), "").unwrap();
+ tree.expand(&root.join("src"));
+ assert_eq!(shown(&tree)[5..], ["src", ".gitignore", "b.log", ".gitignore", "gulpfile.js"], "a nested negation overrides the root's *.log");
+ std::fs::remove_dir_all(root).unwrap();
+ std::fs::remove_dir_all(user).unwrap();
+ }
+
#[test]
fn restores_the_stored_view_state() {
let root = std::env::temp_dir().join(format!("explorer-view-state-test-{}", std::process::id()));
diff --git a/native/crates/app/src/explorer/files_filter.rs b/native/crates/app/src/explorer/files_filter.rs
new file mode 100644
index 00000000000..dd5403f5645
--- /dev/null
+++ b/native/crates/app/src/explorer/files_filter.rs
@@ -0,0 +1,110 @@
+//! explorerViewer.ts `FilesFilter`: `files.exclude` of the item's workspace root and, with `explorer.excludeGitIgnore`,
+//! the `.gitignore` files from the root down to the item's folder.
+
+use std::path::{Path, PathBuf};
+use std::sync::Arc;
+use std::time::SystemTime;
+
+use files::glob::{self, ExcludeExpression, ExcludeTreeEntry, Options};
+use search::ignore_file::IgnoreFile;
+use serde_json::Value;
+
+/// The macOS disk has no PathCaseSensitive, so upstream reads `.gitignore` case-insensitively.
+const IGNORE_CASE: bool = true;
+
+/// What a folder's filter is built from: a folder's entries are read again when it changes.
+#[derive(Clone, PartialEq)]
+pub(super) struct FilterKey {
+ root: PathBuf,
+ exclude: Value,
+ /// With `explorer.excludeGitIgnore`, each `.gitignore` from the root down to the folder, with its mtime.
+ gitignores: Option<Vec<(PathBuf, SystemTime)>>,
+}
+
+impl FilterKey {
+ pub(super) fn new(root: &Path, folder: &Path, exclude: Value, exclude_git_ignore: bool) -> Self {
+ let gitignores = exclude_git_ignore.then(|| {
+ let mut files = Vec::new();
+ for dir in folder.ancestors().take_while(|dir| dir.starts_with(root)) {
+ let file = dir.join(".gitignore");
+ if let Ok(mtime) = std::fs::metadata(&file).and_then(|metadata| metadata.modified()) {
+ files.push((file, mtime));
+ }
+ }
+ files.reverse();
+ files
+ });
+ FilterKey { root: root.to_path_buf(), exclude, gitignores }
+ }
+}
+
+pub(super) struct FilesFilter {
+ root: PathBuf,
+ exclude: ExcludeExpression,
+ /// The `.gitignore` files root first, each with its folder and a trailing `/`; `None` without `excludeGitIgnore`.
+ ignore_files: Option<Vec<(String, Arc<IgnoreFile>)>>,
+}
+
+impl FilesFilter {
+ pub(super) fn new(key: &FilterKey) -> Self {
+ let exclude = glob::parse_exclude_expression(&key.exclude.as_object().cloned().unwrap_or_default(), Options::default());
+ let ignore_files = key.gitignores.as_ref().map(|gitignores| {
+ let mut files: Vec<(String, Arc<IgnoreFile>)> = Vec::new();
+ for (file, _) in gitignores {
+ let dir = file.parent().expect("a .gitignore has a folder").to_string_lossy();
+ // A file deleted since it was listed reads as empty, as the next frame lists it no more.
+ let contents = std::fs::read_to_string(file).unwrap_or_default();
+ let parent = files.last().map(|(_, parent)| parent.clone());
+ files.push((format!("{dir}/"), Arc::new(IgnoreFile::new(&contents, &dir, parent, IGNORE_CASE))));
+ }
+ files
+ });
+ FilesFilter { root: key.root.clone(), exclude, ignore_files }
+ }
+
+ /// `isVisible` for an item of `folder`: shown unless excluded, or excluded but an exception may match beneath it.
+ /// `.gitignore` itself shows while ignore files are read (`filter`).
+ pub(super) fn is_visible(&self, path: &Path, is_dir: bool, folder_excluded: bool, has_sibling: &dyn Fn(&str) -> bool) -> bool {
+ if self.ignore_files.is_some() && path.file_name().is_some_and(|name| name == ".gitignore") {
+ return true;
+ }
+ let evaluation = self.evaluate(path, is_dir, folder_excluded, has_sibling);
+ !evaluation.is_excluded || evaluation.is_visited
+ }
+
+ /// Whether the items of a shown `folder` count as under an excluded folder (`isParentExcluded`): the folder was
+ /// excluded and shown only because an exception may match beneath it. Walks from the root down.
+ pub(super) fn is_folder_excluded(&self, folder: &Path) -> bool {
+ let mut excluded = false;
+ let Ok(relative) = folder.strip_prefix(&self.root) else { return false };
+ let mut dir = self.root.clone();
+ for name in relative.components() {
+ let parent = dir.clone();
+ dir.push(name);
+ excluded = self.evaluate(&dir, true, excluded, &|sibling| parent.join(sibling).exists()).is_excluded;
+ }
+ excluded
+ }
+
+ fn evaluate(&self, path: &Path, is_dir: bool, is_parent_excluded: bool, has_sibling: &dyn Fn(&str) -> bool) -> glob::Evaluation {
+ let relative = path.strip_prefix(&self.root).expect("an Explorer item is under its root").to_string_lossy();
+ let basename = path.file_name().map(|name| name.to_string_lossy());
+ let entry = ExcludeTreeEntry {
+ path: &relative,
+ basename: basename.as_deref(),
+ is_directory: is_dir,
+ is_parent_excluded,
+ is_hidden: self.is_git_ignored(path, is_dir),
+ has_sibling: Some(has_sibling),
+ };
+ glob::evaluate_exclude_tree_entry(&self.exclude, &entry)
+ }
+
+ /// `isGitIgnored`: by the `.gitignore` of the nearest folder above the item that has one.
+ fn is_git_ignored(&self, path: &Path, is_dir: bool) -> bool {
+ let Some(files) = &self.ignore_files else { return false };
+ let path = path.to_string_lossy();
+ let nearest = files.iter().rev().find(|(dir, _)| path.starts_with(dir.as_str()));
+ nearest.is_some_and(|(_, file)| !file.is_path_included_in_traversal(&path, is_dir))
+ }
+}
diff --git a/native/crates/search/src/ignore_file.rs b/native/crates/search/src/ignore_file.rs
new file mode 100644
index 00000000000..5e1a87af062
--- /dev/null
+++ b/native/crates/search/src/ignore_file.rs
@@ -0,0 +1,103 @@
+//! Port of services/search/common/ignoreFile.ts: one `.gitignore` read as globs, falling back to the one of the
+//! folder above it.
+
+use std::sync::Arc;
+
+use files::glob::{self, Glob, Options};
+use serde_json::Value;
+
+#[cfg(test)]
+mod tests;
+
+pub struct IgnoreFile {
+ /// The folder of the file, with a trailing `/`.
+ location: String,
+ parent: Option<Arc<IgnoreFile>>,
+ ignore_case: bool,
+ file_ignored: Glob,
+ file_included: Glob,
+ dir_ignored: Glob,
+ dir_included: Glob,
+}
+
+impl IgnoreFile {
+ pub fn new(contents: &str, location: &str, parent: Option<Arc<IgnoreFile>>, ignore_case: bool) -> Self {
+ // Upstream throws on a trailing `\`, a Windows separator; on macOS it is part of a folder's name.
+ let location = if location.ends_with('/') { location.to_string() } else { format!("{location}/") };
+ let lines: Vec<&str> = contents.split('\n').map(str::trim).filter(|line| !line.is_empty() && !line.starts_with('#')).collect();
+ // Lines ending with `/` apply to folders only.
+ let file_lines: Vec<&str> = lines.iter().copied().filter(|line| !line.ends_with('/')).collect();
+ let expression = |lines: &[&str], negated: bool, trim_for_exclusions: bool| {
+ let mut expression = serde_json::Map::new();
+ for line in lines.iter().filter(|line| line.contains('!') == negated) {
+ expression.insert(line_to_glob(&line.replace('!', ""), &location), Value::Bool(true));
+ }
+ glob::parse_expression(&expression, Options { trim_for_exclusions, ignore_case })
+ };
+ IgnoreFile {
+ file_ignored: expression(&file_lines, false, true),
+ // Upstream's "slight hack": a `!` anywhere makes the line a negation, which may reinclude too much.
+ file_included: expression(&file_lines, true, false),
+ dir_ignored: expression(&lines, false, true),
+ dir_included: expression(&lines, true, false),
+ location,
+ parent,
+ ignore_case,
+ }
+ }
+
+ /// Whether a path is not ignored, its parent folders not checked: walking a tree, they were checked on the way down.
+ pub fn is_path_included_in_traversal(&self, path: &str, is_dir: bool) -> bool {
+ assert!(path.starts_with('/') && !path.ends_with('/'), "Unexpected path format, expected to begin with slash and end without. got:{path}");
+ !self.is_path_ignored(path, is_dir)
+ }
+
+ /// Whether a path or one of its parent folders is ignored.
+ pub fn is_arbitrary_path_ignored(&self, path: &str, is_dir: bool) -> bool {
+ assert!(path.starts_with('/') && !path.ends_with('/'), "Unexpected path format, expected to begin with slash and end without. got:{path}");
+ let segments: Vec<&str> = path.split('/').filter(|segment| !segment.is_empty()).collect();
+ let mut walking_path = String::new();
+ for (index, segment) in segments.iter().enumerate() {
+ walking_path.push('/');
+ walking_path.push_str(segment);
+ let is_last = index == segments.len() - 1;
+ if !self.is_path_included_in_traversal(&walking_path, if is_last { is_dir } else { true }) {
+ return true;
+ }
+ }
+ false
+ }
+
+ fn is_path_ignored(&self, path: &str, is_dir: bool) -> bool {
+ let in_location = match self.ignore_case {
+ true => path.get(..self.location.len()).is_some_and(|start| start.eq_ignore_ascii_case(&self.location)),
+ false => path.starts_with(&self.location),
+ };
+ if !in_location {
+ return false;
+ }
+ let dir_included = is_dir && self.dir_included.is_match(path);
+ if is_dir && self.dir_ignored.is_match(path) && !dir_included {
+ return true;
+ }
+ let file_included = self.file_included.is_match(path);
+ if self.file_ignored.is_match(path) && !file_included {
+ return true;
+ }
+ // A negation here overrides a pattern of a parent file, as in git.
+ if dir_included || file_included {
+ return false;
+ }
+ self.parent.as_ref().is_some_and(|parent| parent.is_path_ignored(path, is_dir))
+ }
+}
+
+/// `gitignoreLineToGlob`: a line without an inner `/` matches at any depth, one with it from the file's folder.
+fn line_to_glob(line: &str, location: &str) -> String {
+ match line.find('/') {
+ None => format!("**/{line}"),
+ Some(index) if index == line.len() - 1 => format!("**/{line}"),
+ Some(0) => format!("{location}{}", &line[1..]),
+ Some(_) => format!("{location}{line}"),
+ }
+}
diff --git a/native/crates/search/src/ignore_file/tests.rs b/native/crates/search/src/ignore_file/tests.rs
new file mode 100644
index 00000000000..f755fce7eee
--- /dev/null
+++ b/native/crates/search/src/ignore_file/tests.rs
@@ -0,0 +1,454 @@
+use super::*;
+
+/// ignoreFile.test.ts `runAssert`, with and without a `/someFolder` prefix; a trailing `/` marks a folder.
+fn check(contents: &str, location: &str, input: &str, should_match: bool, traverse: bool, ignore_case: bool) {
+ let is_dir = input.ends_with('/');
+ let raw = input.trim_end_matches('/');
+ for prefix in ["", "/someFolder"] {
+ let file = IgnoreFile::new(contents, &format!("{prefix}{location}"), None, ignore_case);
+ let path = format!("{prefix}{raw}");
+ let result = if traverse { file.is_path_included_in_traversal(&path, is_dir) } else { file.is_arbitrary_path_ignored(&path, is_dir) };
+ assert_eq!(result, should_match, "{location}: {contents:?} traverse {traverse}, is_dir {is_dir}, {path}");
+ }
+}
+
+fn no_traverses(contents: &str, location: &str, input: &str) {
+ check(contents, location, input, false, true, false);
+}
+
+fn traverses(contents: &str, location: &str, input: &str) {
+ check(contents, location, input, true, true, false);
+}
+
+fn ignore_match(contents: &str, location: &str, input: &str) {
+ check(contents, location, input, true, false, false);
+}
+
+fn no_ignore_match(contents: &str, location: &str, input: &str) {
+ check(contents, location, input, false, false, false);
+}
+
+#[test]
+fn paths_with_trailing_slashes_do_not_match_files() {
+ let i = "node_modules/\n";
+
+ no_ignore_match(i, "/", "/node_modules");
+ ignore_match(i, "/", "/node_modules/");
+
+ no_ignore_match(i, "/", "/inner/node_modules");
+ ignore_match(i, "/", "/inner/node_modules/");
+}
+
+#[test]
+fn parsing_simple_gitignore_files() {
+ let mut i = "node_modules\nout\n";
+
+ ignore_match(i, "/", "/node_modules");
+ no_traverses(i, "/", "/node_modules");
+ ignore_match(i, "/", "/node_modules/file");
+ ignore_match(i, "/", "/dir/node_modules");
+ ignore_match(i, "/", "/dir/node_modules/file");
+
+ ignore_match(i, "/", "/out");
+ no_traverses(i, "/", "/out");
+ ignore_match(i, "/", "/out/file");
+ ignore_match(i, "/", "/dir/out");
+ ignore_match(i, "/", "/dir/out/file");
+
+ i = "/node_modules\n/out\n";
+
+ ignore_match(i, "/", "/node_modules");
+ ignore_match(i, "/", "/node_modules/file");
+ no_ignore_match(i, "/", "/dir/node_modules");
+ no_ignore_match(i, "/", "/dir/node_modules/file");
+
+ ignore_match(i, "/", "/out");
+ ignore_match(i, "/", "/out/file");
+ no_ignore_match(i, "/", "/dir/out");
+ no_ignore_match(i, "/", "/dir/out/file");
+
+ i = "node_modules/\nout/\n";
+
+ no_ignore_match(i, "/", "/node_modules");
+ ignore_match(i, "/", "/node_modules/");
+ ignore_match(i, "/", "/node_modules/file");
+ ignore_match(i, "/", "/dir/node_modules/");
+ no_ignore_match(i, "/", "/dir/node_modules");
+ ignore_match(i, "/", "/dir/node_modules/file");
+
+ ignore_match(i, "/", "/out/");
+ no_ignore_match(i, "/", "/out");
+ ignore_match(i, "/", "/out/file");
+ no_ignore_match(i, "/", "/dir/out");
+ ignore_match(i, "/", "/dir/out/");
+ ignore_match(i, "/", "/dir/out/file");
+}
+
+#[test]
+fn parsing_files_in_folder_exclude() {
+ let mut i = "node_modules/*\n";
+
+ no_ignore_match(i, "/", "/node_modules");
+ no_ignore_match(i, "/", "/node_modules/");
+ traverses(i, "/", "/node_modules");
+ traverses(i, "/", "/node_modules/");
+ ignore_match(i, "/", "/node_modules/something");
+ no_traverses(i, "/", "/node_modules/something");
+ ignore_match(i, "/", "/node_modules/something/else");
+ ignore_match(i, "/", "/node_modules/@types");
+ no_traverses(i, "/", "/node_modules/@types");
+
+ i = "node_modules/**/*\n";
+
+ no_ignore_match(i, "/", "/node_modules");
+ no_ignore_match(i, "/", "/node_modules/");
+ ignore_match(i, "/", "/node_modules/something");
+ ignore_match(i, "/", "/node_modules/something/else");
+ ignore_match(i, "/", "/node_modules/@types");
+}
+
+#[test]
+fn parsing_simple_negations() {
+ let mut i = "node_modules/*\n!node_modules/@types\n";
+
+ no_ignore_match(i, "/", "/node_modules");
+ traverses(i, "/", "/node_modules");
+
+ ignore_match(i, "/", "/node_modules/something");
+ no_traverses(i, "/", "/node_modules/something");
+ ignore_match(i, "/", "/node_modules/something/else");
+
+ no_ignore_match(i, "/", "/node_modules/@types");
+ traverses(i, "/", "/node_modules/@types");
+ traverses(i, "/", "/node_modules/@types/boop");
+
+ i = "*.log\n!important.log\n";
+
+ ignore_match(i, "/", "/test.log");
+ ignore_match(i, "/", "/inner/test.log");
+
+ no_ignore_match(i, "/", "/important.log");
+ no_ignore_match(i, "/", "/inner/important.log");
+
+ no_traverses(i, "/", "/test.log");
+ no_traverses(i, "/", "/inner/test.log");
+ traverses(i, "/", "/important.log");
+ traverses(i, "/", "/inner/important.log");
+}
+
+#[test]
+fn nested_gitignores() {
+ let mut i = "node_modules\nout\n";
+
+ ignore_match(i, "/inner/", "/inner/node_modules");
+ ignore_match(i, "/inner/", "/inner/more/node_modules");
+
+
+ i = "/node_modules\n/out\n";
+
+ ignore_match(i, "/inner/", "/inner/node_modules");
+ no_ignore_match(i, "/inner/", "/inner/more/node_modules");
+ no_ignore_match(i, "/inner/", "/node_modules");
+
+ i = "node_modules/\nout/\n";
+
+ no_ignore_match(i, "/inner/", "/inner/node_modules");
+ ignore_match(i, "/inner/", "/inner/node_modules/");
+ no_ignore_match(i, "/inner/", "/inner/more/node_modules");
+ ignore_match(i, "/inner/", "/inner/more/node_modules/");
+ no_ignore_match(i, "/inner/", "/node_modules");
+}
+
+#[test]
+fn file_extension_matches() {
+ let mut i = "*.js\n";
+
+ no_ignore_match(i, "/", "/myFile.ts");
+ ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+
+ i = "/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ no_ignore_match(i, "/", "/inner/myFile.js");
+
+ i = "**/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ ignore_match(i, "/", "/inner/more/myFile.js");
+
+ i = "inner/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ no_ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ no_ignore_match(i, "/", "/inner/more/myFile.js");
+
+ i = "/inner/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ no_ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ no_ignore_match(i, "/", "/inner/more/myFile.js");
+
+ i = "**/inner/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ no_ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ no_ignore_match(i, "/", "/inner/more/myFile.js");
+
+ i = "**/inner/**/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ no_ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ ignore_match(i, "/", "/inner/more/myFile.js");
+
+ i = "**/more/*.js";
+ no_ignore_match(i, "/", "/myFile.ts");
+ no_ignore_match(i, "/", "/myFile.js");
+ no_ignore_match(i, "/", "/inner/myFile.ts");
+ no_ignore_match(i, "/", "/inner/myFile.js");
+ no_ignore_match(i, "/", "/inner/more/myFile.ts");
+ ignore_match(i, "/", "/inner/more/myFile.js");
+}
+
+#[test]
+fn real_world_example_vscode_js_debug() {
+ let i = ".cache/
+ .profile/
+ .cdp-profile/
+ .headless-profile/
+ .vscode-test/
+ .DS_Store
+ node_modules/
+ out/
+ dist
+ /coverage
+ /.nyc_output
+ demos/web-worker/vscode-pwa-dap.log
+ demos/web-worker/vscode-pwa-cdp.log
+ .dynamic-testWorkspace
+ **/test/**/*.actual
+ /testWorkspace/web/tmp
+ /testWorkspace/**/debug.log
+ /testWorkspace/webview/win/true/
+ *.cpuprofile";
+
+ let included = [
+ "/distro",
+
+ "/inner/coverage",
+ "/inner/.nyc_output",
+
+ "/inner/demos/web-worker/vscode-pwa-dap.log",
+ "/inner/demos/web-worker/vscode-pwa-cdp.log",
+
+ "/testWorkspace/webview/win/true",
+
+ "/a/best/b/c.actual",
+ "/best/b/c.actual",
+ ];
+
+ let excluded = [
+ "/.profile/",
+ "/inner/.profile/",
+
+ "/.DS_Store",
+ "/inner/.DS_Store",
+
+ "/coverage",
+ "/.nyc_output",
+
+ "/demos/web-worker/vscode-pwa-dap.log",
+ "/demos/web-worker/vscode-pwa-cdp.log",
+
+ "/.dynamic-testWorkspace",
+ "/inner/.dynamic-testWorkspace",
+
+ "/test/.actual",
+ "/test/hello.actual",
+ "/a/test/.actual",
+ "/a/test/b.actual",
+ "/a/test/b/.actual",
+ "/a/test/b/c.actual",
+ "/a/b/test/.actual",
+ "/a/b/test/f/c.actual",
+
+ "/testWorkspace/web/tmp",
+
+ "/testWorkspace/debug.log",
+ "/testWorkspace/a/debug.log",
+ "/testWorkspace/a/b/debug.log",
+
+ "/testWorkspace/webview/win/true/",
+
+ "/.cpuprofile",
+ "/a.cpuprofile",
+ "/aa/a.cpuprofile",
+ "/aaa/aa/a.cpuprofile",
+ ];
+
+ for include in included {
+ no_ignore_match(i, "/", include);
+ }
+
+ for exclude in excluded {
+ ignore_match(i, "/", exclude);
+ }
+}
+
+#[test]
+fn real_world_example_vscode() {
+ let i = ".DS_Store
+ .cache
+ npm-debug.log
+ Thumbs.db
+ node_modules/
+ .build/
+ extensions/**/dist/
+ /out*/
+ /extensions/**/out/
+ src/vs/server
+ resources/server
+ build/node_modules
+ coverage/
+ test_data/
+ test-results/
+ yarn-error.log
+ vscode.lsif
+ vscode.db
+ /.profile-oss";
+
+ let included = [
+ "/inner/extensions/dist",
+ "/inner/extensions/boop/dist/test",
+ "/inner/extensions/boop/doop/dist",
+ "/inner/extensions/boop/doop/dist/test",
+ "/inner/extensions/boop/doop/dist/test",
+
+ "/inner/extensions/out/test",
+ "/inner/extensions/boop/out",
+ "/inner/extensions/boop/out/test",
+
+ "/inner/out/",
+ "/inner/out/test",
+ "/inner/out1/",
+ "/inner/out1/test",
+ "/inner/out2/",
+ "/inner/out2/test",
+
+ "/inner/.profile-oss",
+
+ // Files.
+ "/extensions/dist",
+ "/extensions/boop/doop/dist",
+ "/extensions/boop/out",
+ ];
+
+ let excluded = [
+ "/extensions/dist/",
+ "/extensions/boop/dist/test",
+ "/extensions/boop/doop/dist/",
+ "/extensions/boop/doop/dist/test",
+ "/extensions/boop/doop/dist/test",
+
+ "/extensions/out/test",
+ "/extensions/boop/out/",
+ "/extensions/boop/out/test",
+
+ "/out/",
+ "/out/test",
+ "/out1/",
+ "/out1/test",
+ "/out2/",
+ "/out2/test",
+
+ "/.profile-oss",
+ ];
+
+ for include in included {
+ no_ignore_match(i, "/", include);
+ }
+
+ for exclude in excluded {
+ ignore_match(i, "/", exclude);
+ }
+
+}
+
+
+
+fn run_test(pattern: &str, included: &[&str], excluded: &[&str]) {
+ for include in included {
+ no_ignore_match(pattern, "/", include);
+ }
+ for exclude in excluded {
+ ignore_match(pattern, "/", exclude);
+ }
+}
+
+#[test]
+fn various_advanced_constructs_found_in_popular_repos() {
+ run_test(
+ "**/node_modules\n/packages/*/dist",
+ &["/inner/packages/a/dist", "/inner/packages/abc/dist", "/inner/packages/abc/dist/test", "/packages/dist", "/packages/dist/test", "/packages/a/b/dist", "/packages/a/b/dist/test"],
+ &["/node_modules", "/test/node_modules", "/node_modules/test", "/test/node_modules/test", "/packages/a/dist", "/packages/abc/dist", "/packages/abc/dist/test"],
+ );
+ run_test(
+ ".yarn/*\n# !.yarn/cache\n!.yarn/patches\n!.yarn/plugins\n!.yarn/releases\n!.yarn/sdks\n!.yarn/versions",
+ &["/inner/.yarn/test", "/inner/.yarn/cache", "/.yarn/patches", "/.yarn/plugins", "/.yarn/releases", "/.yarn/sdks", "/.yarn/versions"],
+ &["/.yarn/test", "/.yarn/cache"],
+ );
+ run_test(
+ "[._]*s[a-w][a-z]\n[._]s[a-w][a-z]\n*.un~\n*~",
+ &["/.jaa"],
+ &["/~", "/abc~", "/inner/~", "/inner/abc~", "/.un~", "/a.un~", "/test/.un~", "/test/a.un~", "/.saa", "/....saa", "/._._sby", "/inner/._._sby", "/_swz"],
+ );
+ // Upstream lists the patterns of five more repos with no paths to check ("TODO: the rest of these").
+}
+
+#[test]
+fn child_negation_overrides_parent_ignore() {
+ let parent = Arc::new(IgnoreFile::new(".myconfig\n", "/", None, false));
+ let child = IgnoreFile::new("!.myconfig/\n", "/", Some(parent.clone()), false);
+ assert!(!child.is_arbitrary_path_ignored("/.myconfig", true));
+ assert!(!child.is_arbitrary_path_ignored("/.myconfig/settings/test.md", false));
+
+ let child_no_negation = IgnoreFile::new("node_modules/\n", "/", Some(parent), false);
+ assert!(child_no_negation.is_arbitrary_path_ignored("/.myconfig", true));
+ assert!(child_no_negation.is_arbitrary_path_ignored("/.myconfig/settings/test.md", false));
+}
+
+#[test]
+fn child_negation_overrides_parent_ignore_for_files() {
+ let parent = Arc::new(IgnoreFile::new("*.log\n", "/", None, false));
+ let child = IgnoreFile::new("!important.log\n", "/", Some(parent), false);
+ assert!(!child.is_arbitrary_path_ignored("/important.log", false));
+ assert!(child.is_arbitrary_path_ignored("/other.log", false));
+}
+
+#[test]
+fn case_insensitive_ignore_files() {
+ check("node_modules/\n", "/", "/Node_Modules/", false, false, false);
+ check("node_modules/\n", "/", "/Node_Modules/", true, false, true);
+
+ check("NODE_MODULES/\n", "/", "/Node_Modules/", false, false, false);
+ check("NODE_MODULES/\n", "/", "/Node_Modules/", true, false, true);
+
+ let f3 = "\n\t\t\ttemp/*\n\t\t\t!temp/keep\n\t\t";
+ check(f3, "/", "/TEMP/other", false, false, false);
+ check(f3, "/", "/temp/KEEP", true, false, false);
+ check(f3, "/", "/TEMP/other", true, false, true);
+ check(f3, "/", "/TEMP/KEEP", false, false, true);
+}
diff --git a/native/crates/search/src/lib.rs b/native/crates/search/src/lib.rs
index 864b6ba166f..2e7aa4f8d28 100644
--- a/native/crates/search/src/lib.rs
+++ b/native/crates/search/src/lib.rs
@@ -1,6 +1,7 @@
#![forbid(unsafe_code)]
pub mod file_search;
+pub mod ignore_file;
pub mod query;
pub mod ripgrep;
pub mod search_paths;
diff --git a/port/ledger/units/workbench-contrib.md b/port/ledger/units/workbench-contrib.md
index faef594b34e..67b520a5084 100644
--- a/port/ledger/units/workbench-contrib.md
+++ b/port/ledger/units/workbench-contrib.md
@@ -30,7 +30,7 @@ Part of the Units table, generated by `bun port/tools/gen-ledger.ts`; the status
| workbench/contrib/extensions | workbench contribution | M18 | verified | | cargo test -p app extension views_and_pages_draw the_manage_menu_lists_the_extension_context_menu the_manage_menu_installs_a_version_and_toggles_an_ignored_recommendation the_manage_menu_auto_updates_a_publisher_and_toggles_a_workspace_recommendation download_specific_version_picks_a_version_then_a_folder a_vsix_name_rejects_a_path_from_the_gallery install_anyway_installs_an_unsigned_extension install_specific_version_installs_the_picked_version an_activated_extensions_row_shows_its_activation_time the_manage_menu_sets_a_theme_of_the_extension the_views_are_panes extension_bisect bisect_finds_the_extension_and_keeps_it_disabled extension_features the_runtime_status_lists_uncaught_errors_and_messages invalid_contributed static_entries_need_the_proposal group_needs_the_proposal debuggers_merge_by_type_and_keep_the_built_in_values skipped_menu_contributions_are_extension_messages contributed_command_messages invalid_views_and_view_containers_are_extension_messages invalid_configuration_is_an_extension_message invalid_json_validation_is_an_extension_message invalid_colors_and_icons_are_extension_messages invalid_semantic_token_contributions_are_extension_messages invalid_problem_patterns_and_matchers_are_extension_messages invalid_grammars_are_extension_messages invalid_notebook_contributions_are_extension_messages (extensionsViews, extensionQuery, extensionEnablementService tests); cargo test -p exthost all_compatible_versions_follow_the_kind_and_the_engine all_versions_ignore_the_engine_but_not_the_block every_profile; ui-pair `menus/extension-context.json` with `--extensionDevelopmentPath=<repo>/port/fixtures/extensions/menus`, `menus/extension-theme.json`, port/fixtures/extensions/ui-view.json. Out with removed parts: Report Issue & Continue (contrib/issue), the authentication point and the Account Preferences item (services/authentication), Install and Install Pre-Release (Do not Sync) and Sync This Extension (Settings Sync, no sign-in by decision, port/notes.md) |
| workbench/contrib/externalTerminal | workbench contribution | M15 | verified | | workbench/external_terminal.rs: Open New External Terminal (`workbench.action.terminal.openNativeConsole`, cmd+shift+c), with several workspace folders after the Select workspace folder pick (cargo test -p app open_native_console_picks_a_folder_in_a_multi_root_workspace); cargo test -p app external_terminal; ui-pair (port/results/terminal.md) |
| workbench/contrib/externalUriOpener | workbench contribution | M12 | verified | | workbench/opener.rs: externalUriOpenerService.ts getRequestedOpener (workbench.externalUriOpeners globs), chooseOpener, "How would you like to open: {0}" picker; no Simple Browser (out of scope); verified at port-m12b-verify: cargo test -p app opener 4/4; Simple Browser is out of scope by decision |
-| workbench/contrib/files | workbench contribution | M12 | verified | | explorer.rs, dialog.rs, workbench/workspace_editing.rs, workbench/file_compare.rs: cargo test -p app explorer_actions file_actions view_state nest copy_path copied_path_labels compact get_context compressed_navigation explorer_find find_filters files_dropped_from_finder view_title_and_file_actions new_file_creates file_compare focus_view_commands files_that_do_not_resolve open_editors body_limits_clamp sticky pinned_editors tab_scroll tree_guides hover unpin_hover open_with_opens_the_resource the_context_menu_selects_the_row readonly_keys_follow_the_focused_item_and_its_parent a_failed_create_offers a_folder_dropped_on_the_root a_delete_confirmation_follows_the_dialog_style cmd_v_pastes_the_files_finder_copied dragging_a_root_reorders_the_workspace_folders compacts_single_child_folders_into_one_row a_workspace_root_that_fails_to_resolve_is_decorated_with_its_error a_copy_onto_a_dirty_model_reverts_it_to_the_copied_file an_unreadable_folder_expands_to_no_children (explorerFileNestingTrie.test.ts); ui-pair port/fixtures/ui-pair/m12/workspace-folders.json, port/fixtures/ui-pair/m12/compare-saved.json, m12/compare.json, m12/find-in-folder.json, m12/folder-terminal.json, m12/explorer-ops.json, m12/editor-placeholders.json, m12/open-editors.json, m12/tab-scroll.json, m12/explorer-guides.json, m12/pinned-tabs.json (port/results/contextmenu.md). Differences left (port/notes.md milestone 12): a long tooltip breaks one segment earlier (GPUI line wrapper), the pin action loses its hover after Cmd+W until the pointer moves, a shrink sticky tab with a badge has no room for its name. Virtual workspaces: milestone 25; scrollbars: cargo test -p app the_views_and_pages_draw_their_bodies_in_a_scrollable (open-editors through Workbench::scrollable) |
+| workbench/contrib/files | workbench contribution | M12 | verified | | explorer.rs, dialog.rs, workbench/workspace_editing.rs, workbench/file_compare.rs: cargo test -p app explorer_actions file_actions view_state nest copy_path copied_path_labels compact get_context compressed_navigation explorer_find find_filters files_dropped_from_finder view_title_and_file_actions new_file_creates file_compare focus_view_commands files_that_do_not_resolve open_editors body_limits_clamp sticky pinned_editors tab_scroll tree_guides hover unpin_hover open_with_opens_the_resource the_context_menu_selects_the_row readonly_keys_follow_the_focused_item_and_its_parent a_failed_create_offers a_folder_dropped_on_the_root a_delete_confirmation_follows_the_dialog_style cmd_v_pastes_the_files_finder_copied dragging_a_root_reorders_the_workspace_folders compacts_single_child_folders_into_one_row a_workspace_root_that_fails_to_resolve_is_decorated_with_its_error a_copy_onto_a_dirty_model_reverts_it_to_the_copied_file an_unreadable_folder_expands_to_no_children hides_files_exclude_and_gitignore_matches_but_not_exceptions (explorerFileNestingTrie.test.ts, explorerFilesFilter.test.ts); ui-pair port/fixtures/ui-pair/m12/workspace-folders.json, port/fixtures/ui-pair/m12/compare-saved.json, m12/compare.json, m12/find-in-folder.json, m12/folder-terminal.json, m12/explorer-ops.json, m12/editor-placeholders.json, m12/open-editors.json, m12/tab-scroll.json, m12/explorer-guides.json, m12/pinned-tabs.json (port/results/contextmenu.md). Differences left (port/notes.md milestone 12): a long tooltip breaks one segment earlier (GPUI line wrapper), the pin action loses its hover after Cmd+W until the pointer moves, a shrink sticky tab with a badge has no room for its name. Virtual workspaces: milestone 25; scrollbars: cargo test -p app the_views_and_pages_draw_their_bodies_in_a_scrollable (open-editors through Workbench::scrollable) |
| workbench/contrib/folding | workbench contribution | M8 | verified | | `editor.defaultFoldingRangeProvider` picks among extension `FoldingRangeProvider`s from MainThreadLanguageFeatures (workbench/folding_providers.rs): cargo test -p app folding_providers; the setting's enum lists All and the extensions with code, Programming Languages first (`_updateConfigValues`, config registry.rs: cargo test -p config folding_range); `editor.defaultFoldingRangeProvider` picks among extension `FoldingRangeProvider`s from MainThreadLanguageFeatures (workbench/folding_providers.rs): cargo test -p app folding_providers; the setting's enum is not rebuilt for installed extensions; `editor.defaultFoldingRangeProvider` picks among extension `FoldingRangeProvider`s, which come with mainthread/MainThreadLanguageFeatures (port/notes.md milestone 8) |
| workbench/contrib/format | workbench contribution | M13 | verified | | `editor.defaultFormatter` from the extensions with formatters (config registry `list_default_formatters`), the formatter dialog, notification and Configure Default Formatter pick, Format Document With (workbench/format.rs): cargo test -p app format::, cargo test -p config default_formatter; the `formatter.conflict` Formatting language status with Configure... (cargo test -p app two_formatters_without_a_default) |
| workbench/contrib/git | workbench contribution | M14 | removed | | IGitService and its delegate serve only chat and agent sessions (removed by decision) |
diff --git a/port/ledger/units/workbench-services.md b/port/ledger/units/workbench-services.md
index fb2ba53446a..c6b7f5e25b0 100644
--- a/port/ledger/units/workbench-services.md
+++ b/port/ledger/units/workbench-services.md
@@ -70,7 +70,7 @@ Part of the Units table, generated by `bun port/tools/gen-ledger.ts`; the status
| workbench/services/quickinput | workbench service | M9 | verified | | quick_input_view.rs with header drag (cargo test -p app dragging); api-tests quick input 11/11; view state in application storage (cargo test -p app dragging) |
| workbench/services/remote | workbench service | | removed | | no remote or tunnels by decision (port/notes.md); one local extension host |
| workbench/services/request | workbench service | M18 | verified | | the workbench requests through exthost/src/request.rs (NSURLSession), with the user-local `http.proxyAuthorization` as the `Proxy-Authorization` header: cargo test -p exthost request |
-| workbench/services/search | workbench service | M12 | verified | | native/crates/search: QueryBuilder, ripgrep file search and text search with upstream ripgrepTextSearchEngineUtils and TextSearchResult tests, the view's search paths (search_paths.rs, queryBuilder.test.ts): cargo test -p search 43 passed; open editors answer for their files (searchService.ts local results, search_actions.rs add_open_editor_matches): cargo test -p app search_finds_the_text_of_an_unsaved_editor, verified at port-m12b-verify; too many symlink loops rerun without --follow, skipping what was reported (RipgrepSymlinkLoopDetector): cargo test -p search too_many_symlink_loops |
+| workbench/services/search | workbench service | M12 | verified | | native/crates/search: QueryBuilder, ripgrep file search and text search with upstream ripgrepTextSearchEngineUtils and TextSearchResult tests, the view's search paths (search_paths.rs, queryBuilder.test.ts): cargo test -p search 43 passed; ignoreFile.ts (search/src/ignore_file.rs, its ignoreFile.test.ts cases): cargo test -p search ignore_file; open editors answer for their files (searchService.ts local results, search_actions.rs add_open_editor_matches): cargo test -p app search_finds_the_text_of_an_unsaved_editor, verified at port-m12b-verify; too many symlink loops rerun without --follow, skipping what was reported (RipgrepSymlinkLoopDetector): cargo test -p search too_many_symlink_loops |
| workbench/services/secrets | workbench service | M10 | verified | | port/tools/settings-check secrets (same as the reference); the Keychain store of platform/secrets serves the extension host directly |
| workbench/services/sessions | workbench service | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/services/sharedProcess | workbench service | | verified | | no shared process: each kept channel runs in the app process and is checked in its row (extensions: platform/extensionManagement, extensionGalleryManifest: gallery/open-vsx, extensionTipsService: platform/extensionRecommendations, languagePacks: platform/languagePacks); the other channels serve removed features (port/notes.md milestone 20) |
diff --git a/port/notes.md b/port/notes.md
index 45fa04b5171..26fd4a697f8 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -58,7 +58,7 @@ Scope: `code-gpui <folder>` passes the folder to the extension host as its works
Done when: `port/tools/pixel-check` diffs the empty and the folder window (`port/fixtures/workspace`) in all three themes, with every non-anti-aliased difference listed in `port/results/pixels.md`; `cargo test -p app` passes with the tree test.
-- The tree (`explorer.rs`) is read from disk on every render: folders first, then names compared case-insensitively (`FileSorter` default), with `files.exclude`'s default names hidden.
+- The tree (`explorer.rs`) is read from disk on every render: folders first, then names compared case-insensitively (`FileSorter` default), filtered by `files.exclude` and `explorer.excludeGitIgnore` (see Explorer filter, milestone 12).
- pixel-check copies the fixture outside the repository, so the git extension finds no repository and the reference draws no SCM decorations.
- The reference runs with `security.workspace.trust.enabled: false` (no trust dialog) and `workbench.secondarySideBar.defaultVisibility: hidden` (with AI off the secondary side bar is empty).
- shortcut: no file icon theme; the reference is captured with `workbench.iconTheme: null`. Port Seti when the editor opens files.
@@ -297,6 +297,7 @@ Scope shipped so far: `workspace.fs` and file events, Seti file icons and numeri
- Adding and removing workspace folders and untitled workspaces: see "Workspace folder editing" in the milestone 12 section.
- Explorer view state (explorerView.ts `storeTreeViewState`, asyncDataTree `getViewState`): `workbench.explorer.treeViewState` in workspace storage holds `focus`, `selection`, `expanded` and `scrollTop`, with ids `<root URI>::<resource URI>` as explorerModel.ts `getId`. It is restored with the workspace state; items no longer on disk are dropped. Written when the workbench is released or the app quits, since the port has no `onWillSaveState` phase. Tests: `cargo test -p app view_state`.
- File nesting (`explorer/nesting.rs`, explorerFileNestingTrie.ts with the cases of explorerFileNestingTrie.test.ts): `explorer.fileNesting.enabled`, `expand` and `patterns`, read per folder so `.vscode/settings.json` applies. Nest parents get a twistie; a collapsed nest stays collapsed with `expand: true`; `files.exclude` applies after nesting, so an excluded parent still nests. Measured against the reference with ui-pair (Seti theme): nested rows sit one indent deeper with no align offset. Tests: `cargo test -p app nest`.
+- Explorer filter (`explorer/files_filter.rs`, explorerViewer.ts `FilesFilter`; `search/src/ignore_file.rs`, ignoreFile.ts with the cases of ignoreFile.test.ts): `files.exclude` of the item's workspace root with `!` exceptions, and with `explorer.excludeGitIgnore` the `.gitignore` files from the root down to the folder, read case-insensitively (macOS disk, no PathCaseSensitive). An excluded folder an exception may match beneath stays shown and its items count as under an excluded folder; `.gitignore` itself always shows while the setting is on, as upstream's `filter`. Upstream reads a `.gitignore` when the tree first shows it and watches it; the port lists them with their mtimes in the folder's cache key, so an edit shows on the next frame. Not ported: an excluded file open in a visible editor staying shown (`editorsAffectingFilter`), and a folder whose own `.gitignore` upstream already read is never hidden by its parent's (`findSubstr` returns the folder's own file); the port takes the nearest `.gitignore` above the item. Breadcrumbs still hide only the default names (`EXCLUDED_NAMES`). Tests: `cargo test -p search ignore_file`, `cargo test -p app hides_files_exclude_and_gitignore`.
- `files::operations` ports `WorkingCopyFileService` (create, createFolder, move, copy, delete with participants first and `onDidRunWorkingCopyFileOperation` after) and `BulkFileEdits` (consecutive edits of a kind as one operation, `ignoreIfExists`, `ignoreIfNotExists`, `maxSize`, delete keeping contents for undo), with the cases of `bulkFileEdits.test.ts` and `workingCopyFileService.test.ts` that need no text models.
- `MainThreadBulkEdits` (`exthost/src/main_thread_bulk_edits.rs`) applies the file edits of `workspace.applyEdit` in order; `options.contents` arrives as base64. The participant (`main_thread_files.rs`) sends `$onWillRunFileOperation` as a cancellable request, cancelled after `files.participants.timeout` (0 turns participants off), applies the returned edit with the operation's undo group, and sends `$onDidRunFileOperation`. Operations that undo skip participants. Arguments with buffers come with `{"$$ref$$": -1}` for undefined; `rpc.rs` drops those keys as `parseJsonAndRestoreBufferRefs` does.
- Text edits of a workspace edit run on the workbench, which owns the text models (`workbench/bulk_text_edits.rs`, a port of bulkTextEdits.ts): the host thread asks with `applyTextEdits` through `ask_workbench`, version ids are checked first, and an edit to a file without a model reads it from disk. `setEndOfLine` is a model change with `isEolChange` (shortcut: not on the undo stack yet). Notebook cell edits go to the workbench's notebook models (`applyCellEdits`, milestone 17 notebooks); a failing step fails the edit and the file edits before it stay applied, as upstream's `BulkEdit.perform` on a failing step.