Invert condition when opening entries

Co-Authored-By: Brooks Swinnerton <934497+bswinnerton@users.noreply.github.com>
This commit is contained in:
Nathan Sobo 2021-04-13 19:41:38 -06:00
parent e3fbb97ecc
commit e4f41de7bf
2 changed files with 18 additions and 11 deletions

8
.vscode/launch.json vendored
View file

@ -7,15 +7,15 @@
{ {
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "Debug executable 'zed'", "name": "Debug executable 'Zed'",
"cargo": { "cargo": {
"args": [ "args": [
"build", "build",
"--bin=zed", "--bin=Zed",
"--package=zed" "--package=zed"
], ],
"filter": { "filter": {
"name": "zed", "name": "Zed",
"kind": "bin" "kind": "bin"
} }
}, },
@ -63,4 +63,4 @@
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
} }
] ]
} }

View file

@ -444,12 +444,12 @@ pub trait WorktreeHandle {
impl WorktreeHandle for ModelHandle<Worktree> { impl WorktreeHandle for ModelHandle<Worktree> {
fn file(&self, entry_id: u64, app: &AppContext) -> Result<FileHandle> { fn file(&self, entry_id: u64, app: &AppContext) -> Result<FileHandle> {
if self.read(app).has_entry(entry_id) { if self.read(app).has_entry(entry_id) {
Err(anyhow!("entry does not exist in tree"))
} else {
Ok(FileHandle { Ok(FileHandle {
worktree: self.clone(), worktree: self.clone(),
entry_id, entry_id,
}) })
} else {
Err(anyhow!("entry does not exist in tree"))
} }
} }
} }
@ -719,11 +719,18 @@ mod test {
app.read(|ctx| { app.read(|ctx| {
let tree = tree.read(ctx); let tree = tree.read(ctx);
assert_eq!(tree.file_count(), 4); assert_eq!(tree.file_count(), 4);
let results = match_paths(&[tree.clone()], "bna", false, false, 10, ctx.scoped_pool().clone()) let results = match_paths(
.iter() &[tree.clone()],
.map(|result| tree.entry_path(result.entry_id)) "bna",
.collect::<Result<Vec<PathBuf>, _>>() false,
.unwrap(); false,
10,
ctx.scoped_pool().clone(),
)
.iter()
.map(|result| tree.entry_path(result.entry_id))
.collect::<Result<Vec<PathBuf>, _>>()
.unwrap();
assert_eq!( assert_eq!(
results, results,
vec![ vec![