Closes https://github.com/zed-industries/zed/issues/38690 Closes #37353 ### Background On Windows, paths are normally separated by `\`, unlike mac and linux where they are separated by `/`. When editing code in a project that uses a different path style than your local system (e.g. remoting from Windows to Linux, using WSL, and collaboration between windows and unix users), the correct separator for a path may differ from the "native" separator. Previously, to work around this, Zed converted paths' separators in numerous places. This was applied to both absolute and relative paths, leading to incorrect conversions in some cases. ### Solution Many code paths in Zed use paths that are *relative* to either a worktree root or a git repository. This PR introduces a dedicated type for these paths called `RelPath`, which stores the path in the same way regardless of host platform, and offers `Path`-like manipulation APIs. RelPath supports *displaying* the path using either separator, so that we can display paths in a style that is determined at runtime based on the current project. The representation of absolute paths is left untouched, for now. Absolute paths are different from relative paths because (except in contexts where we know that the path refers to the local filesystem) they should generally be treated as opaque strings. Currently we use a mix of types for these paths (std::path::Path, String, SanitizedPath). Release Notes: - N/A --------- Co-authored-by: Cole Miller <cole@zed.dev> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Peter Tripp <petertripp@gmail.com> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
160 lines
2.8 KiB
Protocol Buffer
160 lines
2.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
package zed.messages;
|
|
|
|
message Timestamp {
|
|
uint64 seconds = 1;
|
|
uint32 nanos = 2;
|
|
}
|
|
|
|
message File {
|
|
uint64 worktree_id = 1;
|
|
optional uint64 entry_id = 2;
|
|
string path = 3;
|
|
Timestamp mtime = 4;
|
|
bool is_deleted = 5;
|
|
}
|
|
|
|
message Entry {
|
|
uint64 id = 1;
|
|
bool is_dir = 2;
|
|
string path = 3;
|
|
uint64 inode = 4;
|
|
Timestamp mtime = 5;
|
|
bool is_ignored = 7;
|
|
bool is_external = 8;
|
|
reserved 6;
|
|
reserved 9;
|
|
bool is_fifo = 10;
|
|
optional uint64 size = 11;
|
|
optional string canonical_path = 12;
|
|
}
|
|
|
|
message AddWorktree {
|
|
string path = 1;
|
|
uint64 project_id = 2;
|
|
bool visible = 3;
|
|
}
|
|
|
|
message AddWorktreeResponse {
|
|
uint64 worktree_id = 1;
|
|
string canonicalized_path = 2;
|
|
}
|
|
|
|
message RemoveWorktree {
|
|
uint64 worktree_id = 1;
|
|
}
|
|
|
|
message GetPathMetadata {
|
|
uint64 project_id = 1;
|
|
string path = 2;
|
|
}
|
|
|
|
message GetPathMetadataResponse {
|
|
bool exists = 1;
|
|
string path = 2;
|
|
bool is_dir = 3;
|
|
}
|
|
|
|
message WorktreeMetadata {
|
|
uint64 id = 1;
|
|
string root_name = 2;
|
|
bool visible = 3;
|
|
string abs_path = 4;
|
|
}
|
|
|
|
message ProjectPath {
|
|
uint64 worktree_id = 1;
|
|
string path = 2;
|
|
}
|
|
|
|
message ListRemoteDirectoryConfig {
|
|
bool is_dir = 1;
|
|
}
|
|
|
|
message ListRemoteDirectory {
|
|
uint64 dev_server_id = 1;
|
|
string path = 2;
|
|
ListRemoteDirectoryConfig config = 3;
|
|
}
|
|
|
|
message EntryInfo {
|
|
bool is_dir = 1;
|
|
}
|
|
|
|
message ListRemoteDirectoryResponse {
|
|
repeated string entries = 1;
|
|
repeated EntryInfo entry_info = 2;
|
|
}
|
|
|
|
message CreateProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 worktree_id = 2;
|
|
string path = 3;
|
|
bool is_directory = 4;
|
|
optional bytes content = 5;
|
|
}
|
|
|
|
message RenameProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 entry_id = 2;
|
|
string new_path = 3;
|
|
uint64 new_worktree_id = 4;
|
|
}
|
|
|
|
message CopyProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 entry_id = 2;
|
|
string new_path = 3;
|
|
uint64 new_worktree_id = 5;
|
|
reserved 4;
|
|
}
|
|
|
|
message DeleteProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 entry_id = 2;
|
|
bool use_trash = 3;
|
|
}
|
|
|
|
message ExpandProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 entry_id = 2;
|
|
}
|
|
|
|
message ExpandProjectEntryResponse {
|
|
uint64 worktree_scan_id = 1;
|
|
}
|
|
|
|
message ExpandAllForProjectEntry {
|
|
uint64 project_id = 1;
|
|
uint64 entry_id = 2;
|
|
}
|
|
|
|
message ExpandAllForProjectEntryResponse {
|
|
uint64 worktree_scan_id = 1;
|
|
}
|
|
|
|
message ProjectEntryResponse {
|
|
optional Entry entry = 1;
|
|
uint64 worktree_scan_id = 2;
|
|
}
|
|
|
|
message UpdateWorktreeSettings {
|
|
uint64 project_id = 1;
|
|
uint64 worktree_id = 2;
|
|
string path = 3;
|
|
optional string content = 4;
|
|
optional LocalSettingsKind kind = 5;
|
|
}
|
|
|
|
enum LocalSettingsKind {
|
|
Settings = 0;
|
|
Tasks = 1;
|
|
Editorconfig = 2;
|
|
Debug = 3;
|
|
}
|
|
|
|
message UpdateUserSettings {
|
|
uint64 project_id = 1;
|
|
string contents = 2;
|
|
}
|