parent
71ddb3dad4
commit
06960670bd
8 changed files with 277 additions and 234 deletions
|
@ -50,6 +50,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
use unindent::Unindent as _;
|
||||
use util::{path, separator, uri};
|
||||
use workspace::Pane;
|
||||
|
||||
#[ctor::ctor]
|
||||
|
@ -1459,7 +1460,7 @@ async fn test_project_reconnect(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-1",
|
||||
path!("/root-1"),
|
||||
json!({
|
||||
"dir1": {
|
||||
"a.txt": "a",
|
||||
|
@ -1487,7 +1488,7 @@ async fn test_project_reconnect(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-2",
|
||||
path!("/root-2"),
|
||||
json!({
|
||||
"2.txt": "2",
|
||||
}),
|
||||
|
@ -1496,7 +1497,7 @@ async fn test_project_reconnect(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-3",
|
||||
path!("/root-3"),
|
||||
json!({
|
||||
"3.txt": "3",
|
||||
}),
|
||||
|
@ -1504,9 +1505,11 @@ async fn test_project_reconnect(
|
|||
.await;
|
||||
|
||||
let active_call_a = cx_a.read(ActiveCall::global);
|
||||
let (project_a1, _) = client_a.build_local_project("/root-1/dir1", cx_a).await;
|
||||
let (project_a2, _) = client_a.build_local_project("/root-2", cx_a).await;
|
||||
let (project_a3, _) = client_a.build_local_project("/root-3", cx_a).await;
|
||||
let (project_a1, _) = client_a
|
||||
.build_local_project(path!("/root-1/dir1"), cx_a)
|
||||
.await;
|
||||
let (project_a2, _) = client_a.build_local_project(path!("/root-2"), cx_a).await;
|
||||
let (project_a3, _) = client_a.build_local_project(path!("/root-3"), cx_a).await;
|
||||
let worktree_a1 =
|
||||
project_a1.read_with(cx_a, |project, cx| project.worktrees(cx).next().unwrap());
|
||||
let project1_id = active_call_a
|
||||
|
@ -1533,7 +1536,7 @@ async fn test_project_reconnect(
|
|||
});
|
||||
let (worktree_a2, _) = project_a1
|
||||
.update(cx_a, |p, cx| {
|
||||
p.find_or_create_worktree("/root-1/dir2", true, cx)
|
||||
p.find_or_create_worktree(path!("/root-1/dir2"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -1579,7 +1582,7 @@ async fn test_project_reconnect(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-1/dir1/subdir2",
|
||||
path!("/root-1/dir1/subdir2"),
|
||||
json!({
|
||||
"f.txt": "f-contents",
|
||||
"g.txt": "g-contents",
|
||||
|
@ -1591,7 +1594,7 @@ async fn test_project_reconnect(
|
|||
client_a
|
||||
.fs()
|
||||
.remove_dir(
|
||||
"/root-1/dir1/subdir1".as_ref(),
|
||||
path!("/root-1/dir1/subdir1").as_ref(),
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
..Default::default()
|
||||
|
@ -1606,7 +1609,7 @@ async fn test_project_reconnect(
|
|||
});
|
||||
let (worktree_a3, _) = project_a1
|
||||
.update(cx_a, |p, cx| {
|
||||
p.find_or_create_worktree("/root-1/dir3", true, cx)
|
||||
p.find_or_create_worktree(path!("/root-1/dir3"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -1647,13 +1650,13 @@ async fn test_project_reconnect(
|
|||
.map(|p| p.to_str().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"subdir2",
|
||||
"subdir2/f.txt",
|
||||
"subdir2/g.txt",
|
||||
"subdir2/h.txt",
|
||||
"subdir2/i.txt"
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("subdir2"),
|
||||
separator!("subdir2/f.txt"),
|
||||
separator!("subdir2/g.txt"),
|
||||
separator!("subdir2/h.txt"),
|
||||
separator!("subdir2/i.txt")
|
||||
]
|
||||
);
|
||||
assert!(worktree_a3.read(cx).has_update_observer());
|
||||
|
@ -1680,13 +1683,13 @@ async fn test_project_reconnect(
|
|||
.map(|p| p.to_str().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"subdir2",
|
||||
"subdir2/f.txt",
|
||||
"subdir2/g.txt",
|
||||
"subdir2/h.txt",
|
||||
"subdir2/i.txt"
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("subdir2"),
|
||||
separator!("subdir2/f.txt"),
|
||||
separator!("subdir2/g.txt"),
|
||||
separator!("subdir2/h.txt"),
|
||||
separator!("subdir2/i.txt")
|
||||
]
|
||||
);
|
||||
assert!(project.worktree_for_id(worktree2_id, cx).is_none());
|
||||
|
@ -1719,18 +1722,21 @@ async fn test_project_reconnect(
|
|||
// While client B is disconnected, add and remove files from client A's project
|
||||
client_a
|
||||
.fs()
|
||||
.insert_file("/root-1/dir1/subdir2/j.txt", "j-contents".into())
|
||||
.insert_file(path!("/root-1/dir1/subdir2/j.txt"), "j-contents".into())
|
||||
.await;
|
||||
client_a
|
||||
.fs()
|
||||
.remove_file("/root-1/dir1/subdir2/i.txt".as_ref(), Default::default())
|
||||
.remove_file(
|
||||
path!("/root-1/dir1/subdir2/i.txt").as_ref(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// While client B is disconnected, add and remove worktrees from client A's project.
|
||||
let (worktree_a4, _) = project_a1
|
||||
.update(cx_a, |p, cx| {
|
||||
p.find_or_create_worktree("/root-1/dir4", true, cx)
|
||||
p.find_or_create_worktree(path!("/root-1/dir4"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -1773,13 +1779,13 @@ async fn test_project_reconnect(
|
|||
.map(|p| p.to_str().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"subdir2",
|
||||
"subdir2/f.txt",
|
||||
"subdir2/g.txt",
|
||||
"subdir2/h.txt",
|
||||
"subdir2/j.txt"
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("subdir2"),
|
||||
separator!("subdir2/f.txt"),
|
||||
separator!("subdir2/g.txt"),
|
||||
separator!("subdir2/h.txt"),
|
||||
separator!("subdir2/j.txt")
|
||||
]
|
||||
);
|
||||
assert!(project.worktree_for_id(worktree2_id, cx).is_none());
|
||||
|
@ -2316,14 +2322,14 @@ async fn test_propagate_saves_and_fs_changes(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/a",
|
||||
path!("/a"),
|
||||
json!({
|
||||
"file1.rs": "",
|
||||
"file2": ""
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
|
||||
|
||||
let worktree_a = project_a.read_with(cx_a, |p, cx| p.worktrees(cx).next().unwrap());
|
||||
let project_id = active_call_a
|
||||
|
@ -2409,18 +2415,25 @@ async fn test_propagate_saves_and_fs_changes(
|
|||
client_a
|
||||
.fs()
|
||||
.rename(
|
||||
"/a/file1.rs".as_ref(),
|
||||
"/a/file1.js".as_ref(),
|
||||
path!("/a/file1.rs").as_ref(),
|
||||
path!("/a/file1.js").as_ref(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
client_a
|
||||
.fs()
|
||||
.rename("/a/file2".as_ref(), "/a/file3".as_ref(), Default::default())
|
||||
.rename(
|
||||
path!("/a/file2").as_ref(),
|
||||
path!("/a/file3").as_ref(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
client_a.fs().insert_file("/a/file4", "4".into()).await;
|
||||
client_a
|
||||
.fs()
|
||||
.insert_file(path!("/a/file4"), "4".into())
|
||||
.await;
|
||||
executor.run_until_parked();
|
||||
|
||||
worktree_a.read_with(cx_a, |tree, _| {
|
||||
|
@ -2959,7 +2972,7 @@ async fn test_git_status_sync(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/dir",
|
||||
path!("/dir"),
|
||||
json!({
|
||||
".git": {},
|
||||
"a.txt": "a",
|
||||
|
@ -2972,11 +2985,11 @@ async fn test_git_status_sync(
|
|||
// Initially, a.txt is uncommitted, but present in the index,
|
||||
// and b.txt is unmerged.
|
||||
client_a.fs().set_head_for_repo(
|
||||
"/dir/.git".as_ref(),
|
||||
path!("/dir/.git").as_ref(),
|
||||
&[("b.txt".into(), "B".into()), ("c.txt".into(), "c".into())],
|
||||
);
|
||||
client_a.fs().set_index_for_repo(
|
||||
"/dir/.git".as_ref(),
|
||||
path!("/dir/.git").as_ref(),
|
||||
&[
|
||||
("a.txt".into(), "".into()),
|
||||
("b.txt".into(), "B".into()),
|
||||
|
@ -2984,7 +2997,7 @@ async fn test_git_status_sync(
|
|||
],
|
||||
);
|
||||
client_a.fs().set_unmerged_paths_for_repo(
|
||||
"/dir/.git".as_ref(),
|
||||
path!("/dir/.git").as_ref(),
|
||||
&[(
|
||||
"b.txt".into(),
|
||||
UnmergedStatus {
|
||||
|
@ -3003,7 +3016,7 @@ async fn test_git_status_sync(
|
|||
second_head: UnmergedStatusCode::Deleted,
|
||||
});
|
||||
|
||||
let (project_local, _worktree_id) = client_a.build_local_project("/dir", cx_a).await;
|
||||
let (project_local, _worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| {
|
||||
call.share_project(project_local.clone(), cx)
|
||||
|
@ -3068,15 +3081,15 @@ async fn test_git_status_sync(
|
|||
// Delete b.txt from the index, mark conflict as resolved,
|
||||
// and modify c.txt in the working copy.
|
||||
client_a.fs().set_index_for_repo(
|
||||
"/dir/.git".as_ref(),
|
||||
path!("/dir/.git").as_ref(),
|
||||
&[("a.txt".into(), "a".into()), ("c.txt".into(), "c".into())],
|
||||
);
|
||||
client_a
|
||||
.fs()
|
||||
.set_unmerged_paths_for_repo("/dir/.git".as_ref(), &[]);
|
||||
.set_unmerged_paths_for_repo(path!("/dir/.git").as_ref(), &[]);
|
||||
client_a
|
||||
.fs()
|
||||
.atomic_write("/dir/c.txt".into(), "CC".into())
|
||||
.atomic_write(path!("/dir/c.txt").into(), "CC".into())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
@ -3109,7 +3122,7 @@ async fn test_git_status_sync(
|
|||
// Now remove the original git repository and check that collaborators are notified.
|
||||
client_a
|
||||
.fs()
|
||||
.remove_dir("/dir/.git".as_ref(), RemoveOptions::default())
|
||||
.remove_dir(path!("/dir/.git").as_ref(), RemoveOptions::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
@ -3145,14 +3158,14 @@ async fn test_fs_operations(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/dir",
|
||||
path!("/dir"),
|
||||
json!({
|
||||
"a.txt": "a-contents",
|
||||
"b.txt": "b-contents",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -3283,13 +3296,13 @@ async fn test_fs_operations(
|
|||
.map(|p| p.to_string_lossy())
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"DIR",
|
||||
"DIR/SUBDIR",
|
||||
"DIR/SUBDIR/f.txt",
|
||||
"DIR/e.txt",
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"d.txt"
|
||||
separator!("DIR"),
|
||||
separator!("DIR/SUBDIR"),
|
||||
separator!("DIR/SUBDIR/f.txt"),
|
||||
separator!("DIR/e.txt"),
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("d.txt")
|
||||
]
|
||||
);
|
||||
});
|
||||
|
@ -3301,13 +3314,13 @@ async fn test_fs_operations(
|
|||
.map(|p| p.to_string_lossy())
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"DIR",
|
||||
"DIR/SUBDIR",
|
||||
"DIR/SUBDIR/f.txt",
|
||||
"DIR/e.txt",
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"d.txt"
|
||||
separator!("DIR"),
|
||||
separator!("DIR/SUBDIR"),
|
||||
separator!("DIR/SUBDIR/f.txt"),
|
||||
separator!("DIR/e.txt"),
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("d.txt")
|
||||
]
|
||||
);
|
||||
});
|
||||
|
@ -3327,14 +3340,14 @@ async fn test_fs_operations(
|
|||
.map(|p| p.to_string_lossy())
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"DIR",
|
||||
"DIR/SUBDIR",
|
||||
"DIR/SUBDIR/f.txt",
|
||||
"DIR/e.txt",
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"d.txt",
|
||||
"f.txt"
|
||||
separator!("DIR"),
|
||||
separator!("DIR/SUBDIR"),
|
||||
separator!("DIR/SUBDIR/f.txt"),
|
||||
separator!("DIR/e.txt"),
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("d.txt"),
|
||||
separator!("f.txt")
|
||||
]
|
||||
);
|
||||
});
|
||||
|
@ -3346,14 +3359,14 @@ async fn test_fs_operations(
|
|||
.map(|p| p.to_string_lossy())
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"DIR",
|
||||
"DIR/SUBDIR",
|
||||
"DIR/SUBDIR/f.txt",
|
||||
"DIR/e.txt",
|
||||
"a.txt",
|
||||
"b.txt",
|
||||
"d.txt",
|
||||
"f.txt"
|
||||
separator!("DIR"),
|
||||
separator!("DIR/SUBDIR"),
|
||||
separator!("DIR/SUBDIR/f.txt"),
|
||||
separator!("DIR/e.txt"),
|
||||
separator!("a.txt"),
|
||||
separator!("b.txt"),
|
||||
separator!("d.txt"),
|
||||
separator!("f.txt")
|
||||
]
|
||||
);
|
||||
});
|
||||
|
@ -3570,13 +3583,13 @@ async fn test_buffer_conflict_after_save(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/dir",
|
||||
path!("/dir"),
|
||||
json!({
|
||||
"a.txt": "a-contents",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -3634,13 +3647,13 @@ async fn test_buffer_reloading(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/dir",
|
||||
path!("/dir"),
|
||||
json!({
|
||||
"a.txt": "a\nb\nc",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -3662,7 +3675,11 @@ async fn test_buffer_reloading(
|
|||
let new_contents = Rope::from("d\ne\nf");
|
||||
client_a
|
||||
.fs()
|
||||
.save("/dir/a.txt".as_ref(), &new_contents, LineEnding::Windows)
|
||||
.save(
|
||||
path!("/dir/a.txt").as_ref(),
|
||||
&new_contents,
|
||||
LineEnding::Windows,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
@ -3692,9 +3709,9 @@ async fn test_editing_while_guest_opens_buffer(
|
|||
|
||||
client_a
|
||||
.fs()
|
||||
.insert_tree("/dir", json!({ "a.txt": "a-contents" }))
|
||||
.insert_tree(path!("/dir"), json!({ "a.txt": "a-contents" }))
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -4007,19 +4024,19 @@ async fn test_collaborating_with_diagnostics(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/a",
|
||||
path!("/a"),
|
||||
json!({
|
||||
"a.rs": "let one = two",
|
||||
"other.rs": "",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
|
||||
|
||||
// Cause the language server to start.
|
||||
let _buffer = project_a
|
||||
.update(cx_a, |project, cx| {
|
||||
project.open_local_buffer_with_lsp("/a/other.rs", cx)
|
||||
project.open_local_buffer_with_lsp(path!("/a/other.rs"), cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -4031,7 +4048,7 @@ async fn test_collaborating_with_diagnostics(
|
|||
.await;
|
||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||
&lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![lsp::Diagnostic {
|
||||
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
||||
|
@ -4051,7 +4068,7 @@ async fn test_collaborating_with_diagnostics(
|
|||
.unwrap();
|
||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||
&lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![lsp::Diagnostic {
|
||||
severity: Some(lsp::DiagnosticSeverity::ERROR),
|
||||
|
@ -4125,7 +4142,7 @@ async fn test_collaborating_with_diagnostics(
|
|||
// Simulate a language server reporting more errors for a file.
|
||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||
&lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![
|
||||
lsp::Diagnostic {
|
||||
|
@ -4219,7 +4236,7 @@ async fn test_collaborating_with_diagnostics(
|
|||
// Simulate a language server reporting no errors for a file.
|
||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||
&lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![],
|
||||
},
|
||||
|
@ -4275,7 +4292,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/test",
|
||||
path!("/test"),
|
||||
json!({
|
||||
"one.rs": "const ONE: usize = 1;",
|
||||
"two.rs": "const TWO: usize = 2;",
|
||||
|
@ -4286,7 +4303,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
|||
)
|
||||
.await;
|
||||
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/test", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/test"), cx_a).await;
|
||||
|
||||
// Share a project as client A
|
||||
let active_call_a = cx_a.read(ActiveCall::global);
|
||||
|
@ -4325,7 +4342,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
|||
for file_name in file_names {
|
||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||
&lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(),
|
||||
uri: lsp::Url::from_file_path(Path::new(path!("/test")).join(file_name)).unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![lsp::Diagnostic {
|
||||
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
||||
|
@ -4392,9 +4409,9 @@ async fn test_reloading_buffer_manually(
|
|||
|
||||
client_a
|
||||
.fs()
|
||||
.insert_tree("/a", json!({ "a.rs": "let one = 1;" }))
|
||||
.insert_tree(path!("/a"), json!({ "a.rs": "let one = 1;" }))
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
|
||||
let buffer_a = project_a
|
||||
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
|
||||
.await
|
||||
|
@ -4422,7 +4439,7 @@ async fn test_reloading_buffer_manually(
|
|||
client_a
|
||||
.fs()
|
||||
.save(
|
||||
"/a/a.rs".as_ref(),
|
||||
path!("/a/a.rs").as_ref(),
|
||||
&Rope::from("let seven = 7;"),
|
||||
LineEnding::Unix,
|
||||
)
|
||||
|
@ -4544,39 +4561,45 @@ async fn test_formatting_buffer(
|
|||
"let honey = \"two\"\n"
|
||||
);
|
||||
|
||||
// Ensure buffer can be formatted using an external command. Notice how the
|
||||
// host's configuration is honored as opposed to using the guest's settings.
|
||||
cx_a.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |file| {
|
||||
file.defaults.formatter = Some(SelectedFormatter::List(FormatterList(
|
||||
vec![Formatter::External {
|
||||
command: "awk".into(),
|
||||
arguments: Some(vec!["{sub(/two/,\"{buffer_path}\")}1".to_string()].into()),
|
||||
}]
|
||||
.into(),
|
||||
)));
|
||||
// There is no `awk` command on Windows.
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
// Ensure buffer can be formatted using an external command. Notice how the
|
||||
// host's configuration is honored as opposed to using the guest's settings.
|
||||
cx_a.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |file| {
|
||||
file.defaults.formatter = Some(SelectedFormatter::List(FormatterList(
|
||||
vec![Formatter::External {
|
||||
command: "awk".into(),
|
||||
arguments: Some(
|
||||
vec!["{sub(/two/,\"{buffer_path}\")}1".to_string()].into(),
|
||||
),
|
||||
}]
|
||||
.into(),
|
||||
)));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
executor.allow_parking();
|
||||
project_b
|
||||
.update(cx_b, |project, cx| {
|
||||
project.format(
|
||||
HashSet::from_iter([buffer_b.clone()]),
|
||||
LspFormatTarget::Buffers,
|
||||
true,
|
||||
FormatTrigger::Save,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
buffer_b.read_with(cx_b, |buffer, _| buffer.text()),
|
||||
format!("let honey = \"{}/a.rs\"\n", directory.to_str().unwrap())
|
||||
);
|
||||
executor.allow_parking();
|
||||
project_b
|
||||
.update(cx_b, |project, cx| {
|
||||
project.format(
|
||||
HashSet::from_iter([buffer_b.clone()]),
|
||||
LspFormatTarget::Buffers,
|
||||
true,
|
||||
FormatTrigger::Save,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
buffer_b.read_with(cx_b, |buffer, _| buffer.text()),
|
||||
format!("let honey = \"{}/a.rs\"\n", directory.to_str().unwrap())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test(iterations = 10)]
|
||||
|
@ -4734,7 +4757,7 @@ async fn test_definition(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root",
|
||||
path!("/root"),
|
||||
json!({
|
||||
"dir-1": {
|
||||
"a.rs": "const ONE: usize = b::TWO + b::THREE;",
|
||||
|
@ -4746,7 +4769,9 @@ async fn test_definition(
|
|||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/root/dir-1", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a
|
||||
.build_local_project(path!("/root/dir-1"), cx_a)
|
||||
.await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -4767,7 +4792,7 @@ async fn test_definition(
|
|||
|_, _| async move {
|
||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||
lsp::Location::new(
|
||||
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
|
||||
lsp::Url::from_file_path(path!("/root/dir-2/b.rs")).unwrap(),
|
||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||
),
|
||||
)))
|
||||
|
@ -4798,7 +4823,7 @@ async fn test_definition(
|
|||
|_, _| async move {
|
||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||
lsp::Location::new(
|
||||
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
|
||||
lsp::Url::from_file_path(path!("/root/dir-2/b.rs")).unwrap(),
|
||||
lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)),
|
||||
),
|
||||
)))
|
||||
|
@ -4835,7 +4860,7 @@ async fn test_definition(
|
|||
);
|
||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||
lsp::Location::new(
|
||||
lsp::Url::from_file_path("/root/dir-2/c.rs").unwrap(),
|
||||
lsp::Url::from_file_path(path!("/root/dir-2/c.rs")).unwrap(),
|
||||
lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)),
|
||||
),
|
||||
)))
|
||||
|
@ -4887,7 +4912,7 @@ async fn test_references(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root",
|
||||
path!("/root"),
|
||||
json!({
|
||||
"dir-1": {
|
||||
"one.rs": "const ONE: usize = 1;",
|
||||
|
@ -4899,7 +4924,9 @@ async fn test_references(
|
|||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/root/dir-1", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a
|
||||
.build_local_project(path!("/root/dir-1"), cx_a)
|
||||
.await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -4922,7 +4949,7 @@ async fn test_references(
|
|||
move |params, _| {
|
||||
assert_eq!(
|
||||
params.text_document_position.text_document.uri.as_str(),
|
||||
"file:///root/dir-1/one.rs"
|
||||
uri!("file:///root/dir-1/one.rs")
|
||||
);
|
||||
let rx = rx.clone();
|
||||
async move {
|
||||
|
@ -4951,15 +4978,15 @@ async fn test_references(
|
|||
lsp_response_tx
|
||||
.unbounded_send(Ok(Some(vec![
|
||||
lsp::Location {
|
||||
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/root/dir-1/two.rs")).unwrap(),
|
||||
range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)),
|
||||
},
|
||||
lsp::Location {
|
||||
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/root/dir-1/two.rs")).unwrap(),
|
||||
range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)),
|
||||
},
|
||||
lsp::Location {
|
||||
uri: lsp::Url::from_file_path("/root/dir-2/three.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/root/dir-2/three.rs")).unwrap(),
|
||||
range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)),
|
||||
},
|
||||
])))
|
||||
|
@ -4984,7 +5011,7 @@ async fn test_references(
|
|||
assert_eq!(references[1].buffer, references[0].buffer);
|
||||
assert_eq!(
|
||||
three_buffer.file().unwrap().full_path(cx),
|
||||
Path::new("/root/dir-2/three.rs")
|
||||
Path::new(path!("/root/dir-2/three.rs"))
|
||||
);
|
||||
|
||||
assert_eq!(references[0].range.to_offset(two_buffer), 24..27);
|
||||
|
@ -5138,7 +5165,7 @@ async fn test_document_highlights(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-1",
|
||||
path!("/root-1"),
|
||||
json!({
|
||||
"main.rs": "fn double(number: i32) -> i32 { number + number }",
|
||||
}),
|
||||
|
@ -5150,7 +5177,7 @@ async fn test_document_highlights(
|
|||
.register_fake_lsp("Rust", Default::default());
|
||||
client_a.language_registry().add(rust_lang());
|
||||
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/root-1", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/root-1"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -5175,7 +5202,7 @@ async fn test_document_highlights(
|
|||
.text_document
|
||||
.uri
|
||||
.as_str(),
|
||||
"file:///root-1/main.rs"
|
||||
uri!("file:///root-1/main.rs")
|
||||
);
|
||||
assert_eq!(
|
||||
params.text_document_position_params.position,
|
||||
|
@ -5238,7 +5265,7 @@ async fn test_lsp_hover(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root-1",
|
||||
path!("/root-1"),
|
||||
json!({
|
||||
"main.rs": "use std::collections::HashMap;",
|
||||
}),
|
||||
|
@ -5272,7 +5299,7 @@ async fn test_lsp_hover(
|
|||
),
|
||||
];
|
||||
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/root-1", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/root-1"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -5312,7 +5339,7 @@ async fn test_lsp_hover(
|
|||
.text_document
|
||||
.uri
|
||||
.as_str(),
|
||||
"file:///root-1/main.rs"
|
||||
uri!("file:///root-1/main.rs")
|
||||
);
|
||||
let name = new_server_name.clone();
|
||||
async move {
|
||||
|
@ -5338,7 +5365,7 @@ async fn test_lsp_hover(
|
|||
.text_document
|
||||
.uri
|
||||
.as_str(),
|
||||
"file:///root-1/main.rs"
|
||||
uri!("file:///root-1/main.rs")
|
||||
);
|
||||
assert_eq!(
|
||||
params.text_document_position_params.position,
|
||||
|
@ -5445,7 +5472,7 @@ async fn test_project_symbols(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"crate-1": {
|
||||
"one.rs": "const ONE: usize = 1;",
|
||||
|
@ -5459,7 +5486,9 @@ async fn test_project_symbols(
|
|||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/code/crate-1", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a
|
||||
.build_local_project(path!("/code/crate-1"), cx_a)
|
||||
.await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -5482,7 +5511,7 @@ async fn test_project_symbols(
|
|||
lsp::SymbolInformation {
|
||||
name: "TWO".into(),
|
||||
location: lsp::Location {
|
||||
uri: lsp::Url::from_file_path("/code/crate-2/two.rs").unwrap(),
|
||||
uri: lsp::Url::from_file_path(path!("/code/crate-2/two.rs")).unwrap(),
|
||||
range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||
},
|
||||
kind: lsp::SymbolKind::CONSTANT,
|
||||
|
@ -5513,13 +5542,13 @@ async fn test_project_symbols(
|
|||
buffer_b_2.read_with(cx_b, |buffer, cx| {
|
||||
assert_eq!(
|
||||
buffer.file().unwrap().full_path(cx),
|
||||
Path::new("/code/crate-2/two.rs")
|
||||
Path::new(path!("/code/crate-2/two.rs"))
|
||||
);
|
||||
});
|
||||
|
||||
// Attempt to craft a symbol and violate host's privacy by opening an arbitrary file.
|
||||
let mut fake_symbol = symbols[0].clone();
|
||||
fake_symbol.path.path = Path::new("/code/secrets").into();
|
||||
fake_symbol.path.path = Path::new(path!("/code/secrets")).into();
|
||||
let error = project_b
|
||||
.update(cx_b, |project, cx| {
|
||||
project.open_buffer_for_symbol(&fake_symbol, cx)
|
||||
|
@ -5552,14 +5581,14 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
|
|||
client_a
|
||||
.fs()
|
||||
.insert_tree(
|
||||
"/root",
|
||||
path!("/root"),
|
||||
json!({
|
||||
"a.rs": "const ONE: usize = b::TWO;",
|
||||
"b.rs": "const TWO: usize = 2",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/root", cx_a).await;
|
||||
let (project_a, worktree_id) = client_a.build_local_project(path!("/root"), cx_a).await;
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
.await
|
||||
|
@ -5578,7 +5607,7 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
|
|||
|_, _| async move {
|
||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||
lsp::Location::new(
|
||||
lsp::Url::from_file_path("/root/b.rs").unwrap(),
|
||||
lsp::Url::from_file_path(path!("/root/b.rs")).unwrap(),
|
||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||
),
|
||||
)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue