Add support for projects managed with Yarn (#13644)
TODO: - [ ] File a PR with Yarn to add Zed to the list of supported IDEs. Fixes: https://github.com/zed-industries/zed/issues/10107 Fixes: https://github.com/zed-industries/zed/issues/13706 Release Notes: - Improved experience in projects using Yarn. Run `yarn dlx @yarnpkg/sdks base` in the root of your project in order to elevate your experience. --------- Co-authored-by: Saurabh <79586784+m4saurabh@users.noreply.github.com>
This commit is contained in:
parent
291d64c803
commit
2727f55772
9 changed files with 320 additions and 24 deletions
|
@ -67,7 +67,10 @@ pub trait Fs: Send + Sync {
|
|||
self.remove_file(path, options).await
|
||||
}
|
||||
async fn open_sync(&self, path: &Path) -> Result<Box<dyn io::Read>>;
|
||||
async fn load(&self, path: &Path) -> Result<String>;
|
||||
async fn load(&self, path: &Path) -> Result<String> {
|
||||
Ok(String::from_utf8(self.load_bytes(path).await?)?)
|
||||
}
|
||||
async fn load_bytes(&self, path: &Path) -> Result<Vec<u8>>;
|
||||
async fn atomic_write(&self, path: PathBuf, text: String) -> Result<()>;
|
||||
async fn save(&self, path: &Path, text: &Rope, line_ending: LineEnding) -> Result<()>;
|
||||
async fn canonicalize(&self, path: &Path) -> Result<PathBuf>;
|
||||
|
@ -318,6 +321,11 @@ impl Fs for RealFs {
|
|||
let text = smol::unblock(|| std::fs::read_to_string(path)).await?;
|
||||
Ok(text)
|
||||
}
|
||||
async fn load_bytes(&self, path: &Path) -> Result<Vec<u8>> {
|
||||
let path = path.to_path_buf();
|
||||
let bytes = smol::unblock(|| std::fs::read(path)).await?;
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
async fn atomic_write(&self, path: PathBuf, data: String) -> Result<()> {
|
||||
smol::unblock(move || {
|
||||
|
@ -1433,6 +1441,10 @@ impl Fs for FakeFs {
|
|||
Ok(String::from_utf8(content.clone())?)
|
||||
}
|
||||
|
||||
async fn load_bytes(&self, path: &Path) -> Result<Vec<u8>> {
|
||||
self.load_internal(path).await
|
||||
}
|
||||
|
||||
async fn atomic_write(&self, path: PathBuf, data: String) -> Result<()> {
|
||||
self.simulate_random_delay().await;
|
||||
let path = normalize_path(path.as_path());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue