mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-10 05:37:29 +03:00
Select new files in the project panel after creating them
This commit is contained in:
parent
a19766931d
commit
0ff39f1280
@ -379,7 +379,7 @@ impl FakeFs {
|
||||
async fn simulate_random_delay(&self) {
|
||||
self.executor
|
||||
.upgrade()
|
||||
.expect("excecutor has been dropped")
|
||||
.expect("executor has been dropped")
|
||||
.simulate_random_delay()
|
||||
.await;
|
||||
}
|
||||
@ -647,9 +647,16 @@ impl Fs for FakeFs {
|
||||
let (tx, rx) = smol::channel::unbounded();
|
||||
state.event_txs.push(tx);
|
||||
let path = path.to_path_buf();
|
||||
let executor = self.executor.clone();
|
||||
Box::pin(futures::StreamExt::filter(rx, move |events| {
|
||||
let result = events.iter().any(|event| event.path.starts_with(&path));
|
||||
async move { result }
|
||||
let executor = executor.clone();
|
||||
async move {
|
||||
if let Some(executor) = executor.clone().upgrade() {
|
||||
executor.simulate_random_delay().await;
|
||||
}
|
||||
result
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -295,9 +295,9 @@ impl ProjectPanel {
|
||||
.save(new_path, Default::default(), cx)
|
||||
});
|
||||
Some(cx.spawn(|this, mut cx| async move {
|
||||
save.await?;
|
||||
let new_entry = save.await?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.update_visible_entries(None, cx);
|
||||
this.update_visible_entries(Some((edit_state.worktree_id, new_entry.id)), cx);
|
||||
cx.notify();
|
||||
});
|
||||
Ok(())
|
||||
@ -1005,12 +1005,12 @@ mod tests {
|
||||
assert_eq!(
|
||||
visible_entries_as_strings(&panel, 0..10, cx),
|
||||
&[
|
||||
"v root1 <== selected",
|
||||
"v root1",
|
||||
" > a",
|
||||
" > b",
|
||||
" > C",
|
||||
" .dockerignore",
|
||||
" the-new-filename",
|
||||
" the-new-filename <== selected",
|
||||
"v root2",
|
||||
" > d",
|
||||
" > e",
|
||||
@ -1048,10 +1048,10 @@ mod tests {
|
||||
&[
|
||||
"v root1",
|
||||
" > a",
|
||||
" v b <== selected",
|
||||
" v b",
|
||||
" > 3",
|
||||
" > 4",
|
||||
" another-filename",
|
||||
" another-filename <== selected",
|
||||
" > C",
|
||||
" .dockerignore",
|
||||
" the-new-filename",
|
||||
|
Loading…
Reference in New Issue
Block a user