From 3a78f053f6b410d432ae9a20254206ec628acbb1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 17 Jun 2021 16:25:30 -0700 Subject: [PATCH] Use strings for paths and buffer contents --- zed-rpc/proto/zed.proto | 8 ++++---- zed-rpc/src/peer.rs | 16 ++++++++-------- zed-rpc/src/proto.rs | 2 +- zed/src/worktree.rs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/zed-rpc/proto/zed.proto b/zed-rpc/proto/zed.proto index fb71c63c51f733ef1e6c1637defe64db46eaac51..c64a5abd0596b1ad32b4d38b9672c93e064443e6 100644 --- a/zed-rpc/proto/zed.proto +++ b/zed-rpc/proto/zed.proto @@ -45,7 +45,7 @@ message OpenWorktreeResponse { message OpenBuffer { uint64 worktree_id = 1; - bytes path = 2; + string path = 2; } message OpenBufferResponse { @@ -53,13 +53,13 @@ message OpenBufferResponse { } message Worktree { - repeated bytes paths = 1; + repeated string paths = 1; } message Buffer { uint64 id = 1; - bytes path = 2; - bytes content = 3; + string path = 2; + string content = 3; repeated Operation history = 4; } diff --git a/zed-rpc/src/peer.rs b/zed-rpc/src/peer.rs index 51c5d00737b49e764e0e1c22e995dc1701b6f43f..674ccb43ccdae51da33d78c3433a8b7a73baa072 100644 --- a/zed-rpc/src/peer.rs +++ b/zed-rpc/src/peer.rs @@ -340,7 +340,7 @@ mod tests { }; let response1 = proto::OpenWorktreeResponse { worktree: Some(proto::Worktree { - paths: vec![b"path/one".to_vec()], + paths: vec!["path/one".to_string()], }), }; let request2 = proto::OpenWorktree { @@ -349,30 +349,30 @@ mod tests { }; let response2 = proto::OpenWorktreeResponse { worktree: Some(proto::Worktree { - paths: vec![b"path/two".to_vec(), b"path/three".to_vec()], + paths: vec!["path/two".to_string(), "path/three".to_string()], }), }; let request3 = proto::OpenBuffer { worktree_id: 102, - path: b"path/two".to_vec(), + path: "path/two".to_string(), }; let response3 = proto::OpenBufferResponse { buffer: Some(proto::Buffer { id: 1001, - path: b"path/two".to_vec(), - content: b"path/two content".to_vec(), + path: "path/two".to_string(), + content: "path/two content".to_string(), history: vec![], }), }; let request4 = proto::OpenBuffer { worktree_id: 101, - path: b"path/one".to_vec(), + path: "path/one".to_string(), }; let response4 = proto::OpenBufferResponse { buffer: Some(proto::Buffer { id: 1002, - path: b"path/one".to_vec(), - content: b"path/one content".to_vec(), + path: "path/one".to_string(), + content: "path/one content".to_string(), history: vec![], }), }; diff --git a/zed-rpc/src/proto.rs b/zed-rpc/src/proto.rs index a87fbabf0d6f0920a0f467e3f97df4756046a5c8..162e31df9acb8f7ea2fb7e120905fe80d2b7d4c6 100644 --- a/zed-rpc/src/proto.rs +++ b/zed-rpc/src/proto.rs @@ -131,7 +131,7 @@ mod tests { let message2 = ShareWorktree { worktree: Some(Worktree { - paths: vec![b"ok".to_vec()], + paths: vec!["ok".to_string()], }), } .into_envelope(5, None); diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index f01cc975cd6f95654a1d6549a8c351bb460f1f66..1d837a017a5268ae99ddc5db15bed00373800b45 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -239,7 +239,7 @@ impl Worktree { .spawn(async move { snapshot .paths() - .map(|path| path.as_os_str().as_bytes().to_vec()) + .map(|path| path.to_string_lossy().to_string()) .collect() }) .await;