mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fixed tests
This commit is contained in:
parent
f473eadf2d
commit
1789dfb8b1
@ -47,7 +47,7 @@ impl View for Breadcrumbs {
|
||||
.with_children(Itertools::intersperse_with(breadcrumbs.into_iter(), || {
|
||||
Label::new(" 〉 ".to_string(), theme.breadcrumbs.text.clone()).boxed()
|
||||
}))
|
||||
.scrollable::<BreadcrumbTag, _>(1, None, cx)
|
||||
.scrollable::<BreadcrumbTag, _>(0, None, cx)
|
||||
.contained()
|
||||
.with_style(theme.breadcrumbs.container)
|
||||
.aligned()
|
||||
|
@ -15,7 +15,7 @@ use editor::{
|
||||
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToOffset,
|
||||
ToggleCodeActions, Undo,
|
||||
};
|
||||
use fs::{FakeFs, Fs as _, LineEnding};
|
||||
use fs::{FakeFs, Fs as _, HomeDir, LineEnding};
|
||||
use futures::{channel::mpsc, Future, StreamExt as _};
|
||||
use gpui::{
|
||||
executor::{self, Deterministic},
|
||||
@ -3038,7 +3038,7 @@ async fn test_references(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
|
||||
assert_eq!(references[1].buffer, references[0].buffer);
|
||||
assert_eq!(
|
||||
three_buffer.file().unwrap().full_path(cx),
|
||||
Path::new("three.rs")
|
||||
Path::new("/OUTSIDE_PROJECT/three.rs")
|
||||
);
|
||||
|
||||
assert_eq!(references[0].range.to_offset(two_buffer), 24..27);
|
||||
@ -6130,6 +6130,8 @@ impl TestServer {
|
||||
|
||||
async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient {
|
||||
cx.update(|cx| {
|
||||
cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()));
|
||||
|
||||
let mut settings = Settings::test(cx);
|
||||
settings.projects_online_by_default = false;
|
||||
cx.set_global(settings);
|
||||
|
@ -13,6 +13,7 @@ use smol::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use std::borrow::Cow;
|
||||
use std::cmp;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
io,
|
||||
@ -95,6 +96,14 @@ impl LineEnding {
|
||||
|
||||
pub struct HomeDir(pub PathBuf);
|
||||
|
||||
impl Deref for HomeDir {
|
||||
type Target = PathBuf;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait Fs: Send + Sync {
|
||||
async fn create_dir(&self, path: &Path) -> Result<()>;
|
||||
|
@ -583,7 +583,10 @@ impl Project {
|
||||
cx: &mut gpui::TestAppContext,
|
||||
) -> ModelHandle<Project> {
|
||||
if !cx.read(|cx| cx.has_global::<Settings>()) {
|
||||
cx.update(|cx| cx.set_global(Settings::test(cx)));
|
||||
cx.update(|cx| {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()))
|
||||
});
|
||||
}
|
||||
|
||||
let languages = Arc::new(LanguageRegistry::test());
|
||||
|
@ -1840,23 +1840,27 @@ impl language::File for File {
|
||||
fn full_path(&self, cx: &AppContext) -> PathBuf {
|
||||
let mut full_path = PathBuf::new();
|
||||
let worktree = self.worktree.read(cx);
|
||||
|
||||
if worktree.is_visible() {
|
||||
full_path.push(worktree.root_name());
|
||||
} else {
|
||||
if let Some(path) = worktree.as_local().map(|local| local.abs_path.clone()) {
|
||||
if let Ok(trimmed_path) = path.strip_prefix(cx.global::<HomeDir>().0.as_path()) {
|
||||
if let Ok(trimmed_path) = path.strip_prefix(cx.global::<HomeDir>().as_path()) {
|
||||
full_path.push("~");
|
||||
full_path.push(trimmed_path);
|
||||
} else {
|
||||
full_path.push(path)
|
||||
}
|
||||
} else {
|
||||
full_path.push(Path::new("/host-filesystem/"))
|
||||
full_path.push(Path::new("/OUTSIDE_PROJECT"));
|
||||
full_path.push(worktree.root_name());
|
||||
}
|
||||
}
|
||||
|
||||
if self.path.components().next().is_some() {
|
||||
full_path.push(&self.path);
|
||||
}
|
||||
|
||||
full_path
|
||||
}
|
||||
|
||||
|
@ -38,18 +38,7 @@ pub struct SendKeystroke(String);
|
||||
|
||||
actions!(
|
||||
terminal,
|
||||
[
|
||||
Up,
|
||||
Down,
|
||||
CtrlC,
|
||||
Escape,
|
||||
Enter,
|
||||
Clear,
|
||||
Copy,
|
||||
Paste,
|
||||
ShowCharacterPalette,
|
||||
SearchTest
|
||||
]
|
||||
[Clear, Copy, Paste, ShowCharacterPalette, SearchTest]
|
||||
);
|
||||
|
||||
impl_actions!(terminal, [SendText, SendKeystroke]);
|
||||
|
Loading…
Reference in New Issue
Block a user