collab: Fix project sharing between Windows and Unix (#23680)

Closes #14258

Windows user(host) sharing a project to a guest(using macOS), and host
follows guest:


https://github.com/user-attachments/assets/ba306b6b-23f7-48b1-8ba8-fdc5992d8f00

macOS user(host) sharing a project to a guest(using Windows), and host
follows guest:



https://github.com/user-attachments/assets/c5ee5e78-870d-49e5-907d-8565977a01ae

macOS user edits files in a windows project through collab:



https://github.com/user-attachments/assets/581057cf-e7df-4e56-a0ce-ced74339906a





Release Notes:

- N/A
This commit is contained in:
张小白 2025-02-11 08:12:01 +08:00 committed by GitHub
parent 929c5e76b4
commit c1f162abc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 226 additions and 117 deletions

View file

@ -55,7 +55,10 @@ use parking_lot::Mutex;
use postage::watch;
use rand::prelude::*;
use rpc::AnyProtoClient;
use rpc::{
proto::{FromProto, ToProto},
AnyProtoClient,
};
use serde::Serialize;
use settings::{Settings, SettingsLocation, SettingsStore};
use sha2::{Digest, Sha256};
@ -5360,7 +5363,7 @@ impl LspStore {
project_id: *project_id,
worktree_id: worktree_id.to_proto(),
summary: Some(proto::DiagnosticSummary {
path: worktree_path.to_string_lossy().to_string(),
path: worktree_path.to_proto(),
language_server_id: server_id.0 as u64,
error_count: new_summary.error_count as u32,
warning_count: new_summary.warning_count as u32,
@ -5848,10 +5851,8 @@ impl LspStore {
.ok_or_else(|| anyhow!("worktree not found"))?;
let (old_abs_path, new_abs_path) = {
let root_path = worktree.update(&mut cx, |this, _| this.abs_path())?;
(
root_path.join(&old_path),
root_path.join(&envelope.payload.new_path),
)
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
(root_path.join(&old_path), root_path.join(&new_path))
};
Self::will_rename_entry(
@ -5881,7 +5882,7 @@ impl LspStore {
if let Some(message) = envelope.payload.summary {
let project_path = ProjectPath {
worktree_id,
path: Path::new(&message.path).into(),
path: Arc::<Path>::from_proto(message.path),
};
let path = project_path.path.clone();
let server_id = LanguageServerId(message.language_server_id as usize);
@ -5915,7 +5916,7 @@ impl LspStore {
project_id: *project_id,
worktree_id: worktree_id.to_proto(),
summary: Some(proto::DiagnosticSummary {
path: project_path.path.to_string_lossy().to_string(),
path: project_path.path.as_ref().to_proto(),
language_server_id: server_id.0 as u64,
error_count: summary.error_count as u32,
warning_count: summary.warning_count as u32,
@ -7114,7 +7115,7 @@ impl LspStore {
project_id,
worktree_id: worktree_id.to_proto(),
summary: Some(proto::DiagnosticSummary {
path: path.to_string_lossy().to_string(),
path: path.as_ref().to_proto(),
language_server_id: server_id.0 as u64,
error_count: 0,
warning_count: 0,
@ -7768,7 +7769,7 @@ impl LspStore {
language_server_name: symbol.language_server_name.0.to_string(),
source_worktree_id: symbol.source_worktree_id.to_proto(),
worktree_id: symbol.path.worktree_id.to_proto(),
path: symbol.path.path.to_string_lossy().to_string(),
path: symbol.path.path.as_ref().to_proto(),
name: symbol.name.clone(),
kind: unsafe { mem::transmute::<lsp::SymbolKind, i32>(symbol.kind) },
start: Some(proto::PointUtf16 {
@ -7789,7 +7790,7 @@ impl LspStore {
let kind = unsafe { mem::transmute::<i32, lsp::SymbolKind>(serialized_symbol.kind) };
let path = ProjectPath {
worktree_id,
path: PathBuf::from(serialized_symbol.path).into(),
path: Arc::<Path>::from_proto(serialized_symbol.path),
};
let start = serialized_symbol
@ -8263,7 +8264,7 @@ impl DiagnosticSummary {
path: &Path,
) -> proto::DiagnosticSummary {
proto::DiagnosticSummary {
path: path.to_string_lossy().to_string(),
path: path.to_proto(),
language_server_id: language_server_id.0 as u64,
error_count: self.error_count as u32,
warning_count: self.warning_count as u32,