This commit is contained in:
parent
e768eb0a34
commit
3e68f7fde4
10 changed files with 49 additions and 111 deletions
|
@ -862,14 +862,9 @@ impl Worktree {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load_file(
|
||||
&self,
|
||||
path: &Path,
|
||||
skip_file_contents: bool,
|
||||
cx: &Context<Worktree>,
|
||||
) -> Task<Result<LoadedFile>> {
|
||||
pub fn load_file(&self, path: &Path, cx: &Context<Worktree>) -> Task<Result<LoadedFile>> {
|
||||
match self {
|
||||
Worktree::Local(this) => this.load_file(path, skip_file_contents, cx),
|
||||
Worktree::Local(this) => this.load_file(path, cx),
|
||||
Worktree::Remote(_) => {
|
||||
Task::ready(Err(anyhow!("remote worktrees can't yet load files")))
|
||||
}
|
||||
|
@ -1587,12 +1582,7 @@ impl LocalWorktree {
|
|||
})
|
||||
}
|
||||
|
||||
fn load_file(
|
||||
&self,
|
||||
path: &Path,
|
||||
skip_file_contents: bool,
|
||||
cx: &Context<Worktree>,
|
||||
) -> Task<Result<LoadedFile>> {
|
||||
fn load_file(&self, path: &Path, cx: &Context<Worktree>) -> Task<Result<LoadedFile>> {
|
||||
let path = Arc::from(path);
|
||||
let abs_path = self.absolutize(&path);
|
||||
let fs = self.fs.clone();
|
||||
|
@ -1601,11 +1591,7 @@ impl LocalWorktree {
|
|||
|
||||
cx.spawn(|this, _cx| async move {
|
||||
let abs_path = abs_path?;
|
||||
let text = if skip_file_contents {
|
||||
String::new()
|
||||
} else {
|
||||
fs.load(&abs_path).await?
|
||||
};
|
||||
let text = fs.load(&abs_path).await?;
|
||||
|
||||
let worktree = this
|
||||
.upgrade()
|
||||
|
|
|
@ -467,7 +467,7 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) {
|
|||
let prev_read_dir_count = fs.read_dir_call_count();
|
||||
let loaded = tree
|
||||
.update(cx, |tree, cx| {
|
||||
tree.load_file("one/node_modules/b/b1.js".as_ref(), false, cx)
|
||||
tree.load_file("one/node_modules/b/b1.js".as_ref(), cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -507,7 +507,7 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) {
|
|||
let prev_read_dir_count = fs.read_dir_call_count();
|
||||
let loaded = tree
|
||||
.update(cx, |tree, cx| {
|
||||
tree.load_file("one/node_modules/a/a2.js".as_ref(), false, cx)
|
||||
tree.load_file("one/node_modules/a/a2.js".as_ref(), cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue