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
3 changes: 3 additions & 0 deletions rust/Cargo.lock

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

3 changes: 3 additions & 0 deletions rust/contracts/application-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ meaning; `lithe_protocol::ErrorCode` documents when it is reported:
- `git_untrusted_workspace`: the workspace is not trusted, so Git did not start
- `parse_failed`
- `encoding_unmappable`
- `entry_not_found`: a file change names a path, or a target's parent
directory, that does not exist below its root; nothing changed
- `entry_exists`: a file change's target already exists; nothing was replaced
- `cancelled`
- `timed_out`
- `connection_closed`: the remote connection the request names closed or was lost
Expand Down
36 changes: 36 additions & 0 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ or removing a command fails until the table changes in the same commit.
| `workspace.rankNames` | Pure ranking of candidate names that the platform enumerates itself (`{ query, candidates: [{ name, path? }], context: { openPaths, recentPaths }, limitPerTier? }`). Use it only for lists Core cannot index: Windows remote/WSL roots, symbol lists, navigator lists. Roots Core indexes go through `workspace.searchEverywhere`, so an inventory is never sent back to Core. Returns `matches: [{ index, degree, tier, nameMatchRanges }]` ordered by degree, open/recent tier, recency, then file-name order (fixture `rust/fixtures/search/rank-names-v1.json`) |
| `workspace.planDuplicate` | Name the copy of one project item next to its source (`foo.txt` → `foo copy.txt`, then `foo copy 2.txt`) from the sibling names the host has seen to exist |
| `workspace.planPaste` | Name pasted project items in one destination directory: a free name is kept, a taken one gets the copy suffix, and earlier items of the same paste count as taken |
| `workspace.createEntry` | Create one file, directory or symbolic link below a workspace root without replacing anything |
| `workspace.renameEntry` | Rename one entry to a new path of the same root without replacing anything; a link is renamed as a link |
| `workspace.copyEntry` | Copy one entry, a directory with everything in it, to a new path of the same root without replacing anything; links stay links |
| `workspace.resolveEntry` | Name one existing entry below a workspace root without following it |
| `workspace.reduceDirectoryAction` | Apply "set role", "exclude" or "cancel exclusion" to a root's persisted directory rules and return the complete state to persist |
| `workspace.relocateDirectoryRules` | Move (or drop, after a delete) the directory rule keys of a renamed, moved or deleted subtree, optionally into another workspace root's rules |
| `workspace.repositories` | Discover deterministic Git repository roots for an opened workspace |
Expand Down Expand Up @@ -7439,6 +7443,38 @@ to exist, creates the copy without replacing anything (`FileManager.copyItem`, w
appeared meanwhile, adds the name to `existing` and plans again. After 512 rounds the host reports
the stable `destination_exists` error. Cases are in `rust/fixtures/workspace/file-copy-names-v1.json`.

`workspace.createEntry`, `workspace.renameEntry`, `workspace.copyEntry` and `workspace.resolveEntry`
change and name entries below a local workspace root on a plugin's behalf (plan API-11). Each takes
`root`, the absolute path of the root as the host spells it, and `path`, the entry below it.
`createEntry` takes `{ root, path, kind, text?, linkTarget? }`: `kind` is `file`, `directory` or
`symlink`; a file takes optional UTF-8 `text`, and a link takes the `linkTarget` it stores verbatim,
absolute or relative to the link's directory, which may leave the root or name nothing. On Windows each
`/` of `linkTarget` is stored as `\`, and the link is a directory link when the target is an existing
directory at creation, otherwise a file link. `renameEntry` and `copyEntry` take
`{ root, path, target }`, `target` being the full new path in the same root; `resolveEntry` takes
`{ root, path }`. Every command returns `{ path, fullPath, kind }`: `fullPath` is spelled from the
`root` the host sent, as its open documents name the entry, and `kind` is `file`, `directory`,
`symlink` or `other`.

A path is `/`-separated with no empty, `.` or `..` component, and on Windows every component must be
one Windows stores as written (no reserved name such as `CON`, no trailing dot or space, none of
`\ : * ? " < > |`); the root itself is not an entry. The directory holding the entry must exist and
resolve inside the root, so no entry is created or moved through a link that leaves it; the last
component is never followed, so a link is renamed, copied or resolved as a link, and a copied
directory keeps its links as links. Nothing is replaced: macOS and Linux rename with one exclusive
system call (`renamex_np` with `RENAME_EXCL`, `renameat2` with `RENAME_NOREPLACE`) and fall back to a
check before the rename on volumes that refuse it; Windows renames with `MoveFileExW` without
`MOVEFILE_REPLACE_EXISTING`. A rename that only changes the case of a name on a file system that
ignores case is not a collision, and a target naming the source itself is. A directory is never moved
or copied into itself. A copy that fails part way removes what it created.

Errors are `invalid_request` (a malformed path or root, fields that do not match the `kind`, a
directory moved into itself), `permission_denied` (a parent that resolves outside the root),
`workspace_not_found` (no root), `entry_not_found` (no entry, or no parent directory), `entry_exists`
(the target exists), and `unknown` with the system's message in `details` for anything else, such as
Windows refusing to create a link without Developer Mode or elevation. Saving and moving the open
documents under an entry, the system trash and refreshing the project tree stay with the host.

`history.planEvent` takes `{ event }` and returns `{ snapshots: [{ source, reason }] }`. `source` says
whose text the host records: `beforeChange` (the text an event replaces), `afterChange` (the text it
produced) or `editorBuffer` (unsaved editor text that is discarded). A save or auto-save records
Expand Down
2 changes: 2 additions & 0 deletions rust/crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ lithe-diagnostics = { path = "../diagnostics", features = ["test-support"] }
lithe-execution = { path = "../execution", features = ["test-support"] }
lithe-git = { path = "../git", features = ["test-support"] }
lithe-lsp-transport = { path = "../lsp-transport", features = ["test-support"] }
# The file-change tests create symbolic links the way the kernel does.
lithe-platform = { path = "../platform" }
lithe-project = { path = "../project", features = ["test-support"] }
lithe-workspace = { path = "../workspace", features = ["test-support"] }
serde_yaml_ng = "=0.10.0"
Expand Down
13 changes: 13 additions & 0 deletions rust/crates/core/src/protocol/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,15 @@ pub enum WorkspaceCommand {
RankNames,
/// Plans the name of a duplicated project item (`workspace.planDuplicate`).
PlanDuplicate,
/// Creates a file, directory or symbolic link below a root
/// (`workspace.createEntry`).
CreateEntry,
/// Renames an entry without replacing one (`workspace.renameEntry`).
RenameEntry,
/// Copies an entry without replacing one (`workspace.copyEntry`).
CopyEntry,
/// Names an existing entry below a root (`workspace.resolveEntry`).
ResolveEntry,
/// Plans the destination names of pasted project items (`workspace.planPaste`).
PlanPaste,
/// Applies a directory role, exclusion or cancel action (`workspace.reduceDirectoryAction`).
Expand Down Expand Up @@ -1364,6 +1373,10 @@ impl CoreCommand {
"workspace.orderEntries" => Some(Self::Workspace(WorkspaceCommand::OrderEntries)),
"workspace.rankNames" => Some(Self::Workspace(WorkspaceCommand::RankNames)),
"workspace.planDuplicate" => Some(Self::Workspace(WorkspaceCommand::PlanDuplicate)),
"workspace.createEntry" => Some(Self::Workspace(WorkspaceCommand::CreateEntry)),
"workspace.renameEntry" => Some(Self::Workspace(WorkspaceCommand::RenameEntry)),
"workspace.copyEntry" => Some(Self::Workspace(WorkspaceCommand::CopyEntry)),
"workspace.resolveEntry" => Some(Self::Workspace(WorkspaceCommand::ResolveEntry)),
"workspace.planPaste" => Some(Self::Workspace(WorkspaceCommand::PlanPaste)),
"workspace.reduceDirectoryAction" => {
Some(Self::Workspace(WorkspaceCommand::ReduceDirectoryAction))
Expand Down
20 changes: 20 additions & 0 deletions rust/crates/core/src/runtime/dispatcher/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ pub(super) fn dispatch(
payload,
crate::project::file_operations::plan_paste_command,
),
WorkspaceCommand::CreateEntry => plugin_response(
id,
payload,
crate::project::file_changes::create_entry_command,
),
WorkspaceCommand::RenameEntry => plugin_response(
id,
payload,
crate::project::file_changes::rename_entry_command,
),
WorkspaceCommand::CopyEntry => plugin_response(
id,
payload,
crate::project::file_changes::copy_entry_command,
),
WorkspaceCommand::ResolveEntry => plugin_response(
id,
payload,
crate::project::file_changes::resolve_entry_command,
),
WorkspaceCommand::ReduceDirectoryAction => plugin_response(
id,
payload,
Expand Down
Loading
Loading