Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 26 additions & 14 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,26 @@ runs every case of `rust/fixtures/editor/group-layout-v1.json` through them.
and returns `{hidden: boolean[], watchedDespiteHiding: boolean[]}` with one answer per entry, in request order. `path`
is workspace-relative with `/` separators; `isDirectory` is `true` for a folder, `false` for a file and omitted when the
host does not know (every component may then be a folder). The two lists are the user's own entries: Core adds the
built-in folders and patterns, and a `!entry` turns a built-in off. Matching ignores case. A folder name hides the folder,
default folders and patterns, and a `!entry` turns a default off. Matching ignores case. A folder name hides the folder,
everything below it and a file with that exact name (a linked worktree's `.git` file). `hidden` means the tree, search and
Local History leave the path out; `watchedDespiteHiding` marks the hidden project configuration folder (`.lithe`) whose file
events must still be delivered, except the built-in noise below it such as `.lithe/run/local.json`. Hosts send all children
of a directory in one call. `workspace.visibilityDefaults` takes `{}` and returns the built-in lists
of a directory in one call. `workspace.visibilityDefaults` takes `{}` and returns the default lists
(`hiddenDirectoryNames`, `hiddenFilePatterns`, `builtInPatterns`, `configurationDirectory`, `configurationPattern`) so hosts
display them without keeping a copy. Both live in `rust/crates/core-rules` like `keymap.modifierGestureStep` and are tested
against `rust/fixtures/workspace/visibility-v1.json`.

The default folders are Core's own (`.git`, `.worktree`, `.worktrees`) plus the folder names the enabled plugins declare;
Core names no language or tool folder itself. The default file patterns are `.DS_Store`, the root `.lithe/**` and
`.lithe/run/local.json`. `workspace.configureVisibility` accepts `{plugins: [{manifest}]}`, the manifests of every enabled
plugin, and replaces the declared names with theirs: each build system's `layout.hiddenDirectoryNames` (its generated
output, such as `target`) and the directory markers of each VCS provider (its metadata, such as `.svn`). It returns
`{hiddenDirectoryNames, rejected: [{index, error}]}`: every declared name, sorted, and the manifests that failed
validation, which contribute nothing. The names are process-wide and apply from the next request, listing or scan: the
tree, search, file events, Local History's default ignored folders, run discovery, build detection and VCS root and
repository discovery. Hosts send the full list at startup and whenever a plugin is enabled, disabled, installed or
removed; `{plugins: []}` clears it. A malformed payload is `invalid_request`.

## Terminal link targets

`terminal.parseLinkTarget` accepts `{texts: string[], baseDirectory?, homeDirectory?, providerSchemes?: string[]}`
Expand Down Expand Up @@ -542,11 +553,11 @@ or removing a command fails until the table changes in the same commit.
| `plugins.marketplace.validateIndex` | Validate a marketplace index and report each plugin's availability for one platform |
| `plugins.marketplace.resolveSource` | Resolve a user-entered marketplace source to the index URL to fetch |
| `plugins.marketplace.installReview` | List a package's permissions and programs, and those not yet approved |
| `workspace.snapshot` | Enumerate visible workspace nodes and relative file paths; `nestedWorktrees` lists linked worktrees checked out inside their own repository, which are left out of the tree, files, and search index; the built-in hidden names are skipped without being read, and include `node_modules`, Python virtual environments (`.venv`, `venv`), `__pycache__` and `*.pyc` files; `includeTree: false` returns only `files` and a childless `root`; `files` (and the tree, when included) keep the lowercase traversal order that bounded consumers such as Windows Quick Open rely on, not the natural display order of `workspace.listDirectories` |
| `workspace.snapshot` | Enumerate visible workspace nodes and relative file paths; `nestedWorktrees` lists linked worktrees checked out inside their own repository, which are left out of the tree, files, and search index; hidden folders, Core's own and the ones enabled plugins declare through `workspace.configureVisibility`, are skipped without being read; `includeTree: false` returns only `files` and a childless `root`; `files` (and the tree, when included) keep the lowercase traversal order that bounded consumers such as Windows Quick Open rely on, not the natural display order of `workspace.listDirectories` |
| `workspace.releaseIndexing` | Retire a policy and clear index/cache data at project close; accepts `root`, optional `ownerId`, and that owner's last observed `revision`, returns `released`; an old close must not retire a new generation |
| `workspace.configureIndexing` | Install a process-local, canonical-root indexing policy before workspace consumers run; returns a monotonic revision, effective directory reasons and Git failure state; see `rust/fixtures/workspace/indexing-policy-v1.json` |
| `workspace.refreshIndexing` | Refresh external Git decisions for a live `root`, `ownerId`, `revision` lease without changing preferences or release tokens; returns lazy `IndexingStatus` |
| `workspace.filterChanges` | Filter an array of workspace-relative paths, or `{ paths, hiddenFilePatterns }` whose `!` entries turn default exclusions off, against Core's default build/cache exclusions; preserve order, spelling, and the empty root path. Native event loss bypasses filtering. Hosts relativize to the most specific explicit watch root and retain explicitly watched files |
| `workspace.filterChanges` | Filter an array of workspace-relative paths, or `{ paths, hiddenFilePatterns }` whose `!` entries turn default exclusions off, against Core's default hidden folders and patterns, including the folders enabled plugins declare; preserve order, spelling, and the empty root path. Native event loss bypasses filtering. Hosts relativize to the most specific explicit watch root and retain explicitly watched files |
| `workspace.listDirectories` | Return one visible level of children for each requested workspace-relative directory (`""` is the root); missing, hidden, symlinked, or nested-worktree paths are omitted, and each listing reports the nested worktrees it left out. Child directories have `children: []` only when a shallow probe proves them visibly empty; otherwise children remain omitted (unloaded), with no recursive tree allocation. Children list directories first, then names in IDEA's natural file-name order (digit runs compare by value, case-insensitive, `-` next to `_`; fixture `rust/fixtures/workspace/file-name-order-v1.json`) |
| `workspace.orderEntries` | Order natively enumerated directory siblings |
| `workspace.projectTree.rows` | Say which loaded project tree nodes show as rows, keep the selection on a row that shows, and find the row the top of the view was on, without reading the disk (from `lithe-project-tree`) |
Expand Down Expand Up @@ -605,7 +616,8 @@ or removing a command fails until the table changes in the same commit.
| `editor.groupLayout.reduce` | Apply one transition to the editor groups and the tree that divides the editor area among them: a workbench state action, opening a tab, dropping a dragged tab or removing empty groups (from `lithe-editor-layout`) |
| `editor.groupLayout.dropTargets` | Say which places of each editor group accept a dragged tab (from `lithe-editor-layout`) |
| `workspace.classifyVisibility` | Classify a batch of workspace-relative paths as hidden or visible. The rule lives in `lithe-core-rules` so the Windows frontend can run it synchronously |
| `workspace.visibilityDefaults` | Return the built-in hidden-path lists (from `lithe-core-rules`) |
| `workspace.visibilityDefaults` | Return the default hidden-path lists, Core's own and the folders enabled plugins declare (from `lithe-core-rules`) |
| `workspace.configureVisibility` | Replace the folder names enabled plugins declare as hidden (build systems' `layout.hiddenDirectoryNames`, VCS providers' directory markers) and return them with the rejected manifests |
| `workbench.chromeLayout.reduce` | Apply one transition to the rearrangeable workbench chrome: stripe, title bar and status bar button placement, hidden stripe buttons and open tool panels (from `lithe-core-rules`) |
| `workbench.notifications.reduceReadState` | Apply one notification arrival or mark a window's history read; return bounded unread identities and the ready-to-render count (from `lithe-core-rules`) |
| `terminal.parseLinkTarget` | Resolve terminal link candidates into file or external targets |
Expand Down Expand Up @@ -922,9 +934,9 @@ becomes a listed repository when Git can open it: a `.git` directory needs
the marker's directory) that exists and holds `HEAD`. A stale submodule or
worktree pointer whose gitdir was removed is not listed, because status and
reference loads for the whole workspace would otherwise fail for it. The default traversal
skips dot-prefixed descendant directories and the built-in workspace hidden
directory names (including `.build`, `node_modules`, `.venv`, `venv`, `__pycache__`,
`target`, `build`, `DerivedData`, `dist` and `coverage`). `.worktree` and `.worktrees` remain
skips dot-prefixed descendant directories and the folder names enabled plugins
declare through `workspace.configureVisibility` (such as a build system's `target`).
`.worktree` and `.worktrees` remain
traversable checkout containers; the same exclusions apply inside them.
Traversal continues below eligible discovered repositories, including ordinary
`vendor` source checkouts. An explicitly opened root and its containing repository
Expand Down Expand Up @@ -2303,10 +2315,10 @@ scheme's ignored-file color; Windows tolerates the optional status but does not
currently render this foreground.

`includeGeneratedFileNames` opts into a separate in-memory names-only index:
built-in build/dependency directory exclusions (including `.build` and `target`)
do not suppress names, even when callers pass the same default exclusions.
Git metadata and nested worktrees remain excluded; custom directory names and
file/path globs still apply. It does not enable generated-file content or symbol
the folders enabled plugins declare as generated output (a build system's
`layout.hiddenDirectoryNames`, such as `target`) do not suppress names, even when
callers also pass them. VCS metadata, Core's own folders and nested worktrees remain
excluded; other custom directory names and file/path globs still apply. It does not enable generated-file content or symbol
indexing and does not change `workspace.search`, tree, watcher, or replacement
visibility. Names share index invalidation and reported file updates; changes
inside unwatched generated directories require workspace/index refresh. No index
Expand Down Expand Up @@ -3346,8 +3358,8 @@ and an optional `storageLimitBytes` (default
Patterns use the hidden-path glob syntax; regexes use Rust `regex` syntax,
case-insensitive, matched unanchored against the `/`-separated relative path.
A matching file is not recorded, existing entries stay listed, and an invalid
or empty regex never matches. Built-in dependency, cache and build output
folders (such as `node_modules`, `.venv`, `target`) also apply as `**/name/`
or empty regex never matches. The default hidden folders, Core's own and the
ones enabled plugins declare (such as a build system's `target`), also apply as `**/name/`
patterns, for baselines and edits alike; a `!**/name/` or `!name` pattern turns
one off, and saving drops baselines the current rules reject. `history.ignorePreview` accepts the
same `ignoreRules`, optional `hiddenFilePatterns`, an optional relative
Expand Down
6 changes: 4 additions & 2 deletions rust/contracts/vcs-provider-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ call.
Roots come from static markers; detection never starts a process. One
breadth-first walk reads the markers directly inside each directory down to
eight levels below the workspace, at most 20,000 directories. It never enters a
marker directory (`.git`, `.svn`), a symbolic link, or a dependency or build
directory such as `node_modules`, `target`, or `.worktrees`. When the workspace
marker directory (`.git`, `.svn`), a symbolic link, or a folder the default
visibility rules hide: Core's `.worktree` and `.worktrees` and the folder names
enabled plugins declare through `workspace.configureVisibility`, such as a build
system's `target`. When the workspace
itself has no marker, its ancestors are checked, because a Subversion working
copy has one `.svn` at its top; the enclosing root's `id` is `..`, `../..`, ….
`truncated` is `true` only when the directory budget ran out, so a root may be
Expand Down
12 changes: 12 additions & 0 deletions rust/crates/build/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ pub fn validate_declarations(
}

impl BuildSystemDeclaration {
/// Folder names every workspace hides at any depth while the plugin is
/// enabled (`layout.hiddenDirectoryNames`), sorted and unique once validated.
pub fn hidden_directory_names(&self) -> &[String] {
self.layout
.as_ref()
.map_or(&[], |layout| &layout.hidden_directory_names)
}

fn validate(&mut self, field: &str, context: &DeclarationContext<'_>) -> Validation<()> {
if !is_entry_identifier(&self.id) {
return Err(invalid(
Expand Down Expand Up @@ -213,6 +221,10 @@ impl BuildSystemDeclaration {
&format!("{field}.layout.excluded"),
false,
)?;
check_directory_names(
&mut layout.hidden_directory_names,
&format!("{field}.layout.hiddenDirectoryNames"),
)?;
}
self.validate_option_emission(field)
}
Expand Down
29 changes: 29 additions & 0 deletions rust/crates/build/src/manifest/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,35 @@ pub(crate) fn check_paths(values: &mut Vec<String>, field: &str, glob: bool) ->
Ok(())
}

/// Folder names matched against one path component at any depth. A name is
/// literal: it holds no separator or glob character, is not `.` or `..`,
/// and does not start with `!`, which users write to turn a default off.
pub(crate) fn check_directory_names(values: &mut Vec<String>, field: &str) -> Validation<()> {
if values.len() > MAX_LIST {
return Err(invalid(field, "The list is too long."));
}
for (index, value) in values.iter().enumerate() {
let literal = !value.is_empty()
&& value.len() <= 255
&& value.trim() == value
&& value != "."
&& value != ".."
&& !value.starts_with('!')
&& !value.chars().any(|character| {
character.is_control() || matches!(character, '/' | '\\' | '*' | '?' | '[' | ']')
});
if !literal {
return Err(PluginRejection::at(
"plugin.path.invalid",
format!("{field}[{index}]"),
"Directory names are single path components without glob characters.",
));
}
}
*values = sorted_unique(std::mem::take(values));
Ok(())
}

pub(crate) fn check_regex(value: &str, field: &str, groups: usize) -> Validation<Regex> {
let compiled = (value.len() <= MAX_REGEX)
.then(|| Regex::new(value).ok())
Expand Down
10 changes: 8 additions & 2 deletions rust/crates/build/src/manifest/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ pub(crate) struct SyncDeclaration {
pub(crate) watch: Vec<String>,
}

/// Output directories excluded from every project, relative to each
/// project directory.
/// Where the build system puts files nobody edits.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub(crate) struct LayoutDeclaration {
/// Output directories excluded from every project, relative to each
/// project directory.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(crate) excluded: Vec<String>,
/// Folder names, such as `target` or `node_modules`, that every
/// workspace hides at any depth while the plugin is enabled: the tree,
/// search, watchers, local history and every workspace walk skip them.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(crate) hidden_directory_names: Vec<String>,
}

impl BuildSystemDeclaration {
Expand Down
2 changes: 2 additions & 0 deletions rust/crates/core-rules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//! This crate holds rules that are small, deterministic and sit on a synchronous hot path
//! (for example a gesture recognizer that runs on every native key event). It performs no
//! file-system, process, thread or clock access: time is always supplied by the caller.
//! The only process-wide state is the folder names enabled plugins hide, which
//! [`visibility::set_plugin_hidden_directories`] replaces as a whole.
//!
//! `lithe-core` links this crate as a normal dependency and exposes each rule through its JSON
//! command dispatch, so hosts reach the rules over the usual Core C ABI. Rule failures use
Expand Down
Loading
Loading