Allow opening non-extant files (#9256)
Fixes #7400 Release Notes: - Improved the `zed` command to not create files until you save them in the editor ([#7400](https://github.com/zed-industries/zed/issues/7400)).
This commit is contained in:
parent
e792c1a5c5
commit
646f69583a
11 changed files with 242 additions and 152 deletions
|
@ -875,6 +875,41 @@ mod tests {
|
|||
WorkspaceHandle,
|
||||
};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_open_non_existing_file(cx: &mut TestAppContext) {
|
||||
let app_state = init_test(cx);
|
||||
app_state
|
||||
.fs
|
||||
.as_fake()
|
||||
.insert_tree(
|
||||
"/root",
|
||||
json!({
|
||||
"a": {
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
|
||||
cx.update(|cx| {
|
||||
open_paths(
|
||||
&[PathBuf::from("/root/a/new")],
|
||||
app_state.clone(),
|
||||
workspace::OpenOptions::default(),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(cx.read(|cx| cx.windows().len()), 1);
|
||||
|
||||
let workspace = cx.windows()[0].downcast::<Workspace>().unwrap();
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
assert!(workspace.active_item_as::<Editor>(cx).is_some())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_open_paths_action(cx: &mut TestAppContext) {
|
||||
let app_state = init_test(cx);
|
||||
|
@ -1657,6 +1692,9 @@ mod tests {
|
|||
},
|
||||
"excluded_dir": {
|
||||
"file": "excluded file contents",
|
||||
"ignored_subdir": {
|
||||
"file": "ignored subfile contents",
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -2305,7 +2343,7 @@ mod tests {
|
|||
(file3.clone(), DisplayPoint::new(0, 0), 0.)
|
||||
);
|
||||
|
||||
// Go back to an item that has been closed and removed from disk, ensuring it gets skipped.
|
||||
// Go back to an item that has been closed and removed from disk
|
||||
workspace
|
||||
.update(cx, |_, cx| {
|
||||
pane.update(cx, |pane, cx| {
|
||||
|
@ -2331,7 +2369,7 @@ mod tests {
|
|||
.unwrap();
|
||||
assert_eq!(
|
||||
active_location(&workspace, cx),
|
||||
(file1.clone(), DisplayPoint::new(10, 0), 0.)
|
||||
(file2.clone(), DisplayPoint::new(0, 0), 0.)
|
||||
);
|
||||
workspace
|
||||
.update(cx, |w, cx| w.go_forward(w.active_pane().downgrade(), cx))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue