Merge branch 'main' into people-panel
This commit is contained in:
+50
-4
@@ -1445,6 +1445,7 @@ mod tests {
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
assert!(!editor.is_dirty(cx.as_ref()));
|
||||
assert_eq!(editor.title(cx.as_ref()), "untitled");
|
||||
assert!(editor.language(cx).is_none());
|
||||
editor.insert(&Insert("hi".into()), cx);
|
||||
assert!(editor.is_dirty(cx.as_ref()));
|
||||
});
|
||||
@@ -1455,7 +1456,7 @@ mod tests {
|
||||
});
|
||||
cx.simulate_new_path_selection(|parent_dir| {
|
||||
assert_eq!(parent_dir, dir.path());
|
||||
Some(parent_dir.join("the-new-name"))
|
||||
Some(parent_dir.join("the-new-name.rs"))
|
||||
});
|
||||
cx.read(|cx| {
|
||||
assert!(editor.is_dirty(cx));
|
||||
@@ -1468,7 +1469,11 @@ mod tests {
|
||||
.await;
|
||||
cx.read(|cx| {
|
||||
assert!(!editor.is_dirty(cx));
|
||||
assert_eq!(editor.title(cx), "the-new-name");
|
||||
assert_eq!(editor.title(cx), "the-new-name.rs");
|
||||
});
|
||||
// The language is assigned based on the path
|
||||
editor.read_with(&cx, |editor, cx| {
|
||||
assert_eq!(editor.language(cx).unwrap().name(), "Rust")
|
||||
});
|
||||
|
||||
// Edit the file and save it again. This time, there is no filename prompt.
|
||||
@@ -1483,7 +1488,7 @@ mod tests {
|
||||
editor
|
||||
.condition(&cx, |editor, cx| !editor.is_dirty(cx))
|
||||
.await;
|
||||
cx.read(|cx| assert_eq!(editor.title(cx), "the-new-name"));
|
||||
cx.read(|cx| assert_eq!(editor.title(cx), "the-new-name.rs"));
|
||||
|
||||
// Open the same newly-created file in another pane item. The new editor should reuse
|
||||
// the same buffer.
|
||||
@@ -1491,7 +1496,7 @@ mod tests {
|
||||
workspace.open_new_file(&OpenNew(app_state.clone()), cx);
|
||||
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
|
||||
assert!(workspace
|
||||
.open_entry((tree.id(), Path::new("the-new-name").into()), cx)
|
||||
.open_entry((tree.id(), Path::new("the-new-name.rs").into()), cx)
|
||||
.is_none());
|
||||
});
|
||||
let editor2 = workspace.update(&mut cx, |workspace, cx| {
|
||||
@@ -1507,6 +1512,47 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_setting_language_when_saving_as_single_file_worktree(
|
||||
mut cx: gpui::TestAppContext,
|
||||
) {
|
||||
let dir = TempDir::new("test-new-file").unwrap();
|
||||
let app_state = cx.update(test_app_state);
|
||||
let (_, workspace) = cx.add_window(|cx| Workspace::new(&app_state, cx));
|
||||
|
||||
// Create a new untitled buffer
|
||||
let editor = workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.open_new_file(&OpenNew(app_state.clone()), cx);
|
||||
workspace
|
||||
.active_item(cx)
|
||||
.unwrap()
|
||||
.to_any()
|
||||
.downcast::<Editor>()
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
assert!(editor.language(cx).is_none());
|
||||
editor.insert(&Insert("hi".into()), cx);
|
||||
assert!(editor.is_dirty(cx.as_ref()));
|
||||
});
|
||||
|
||||
// Save the buffer. This prompts for a filename.
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.save_active_item(&Save, cx)
|
||||
});
|
||||
cx.simulate_new_path_selection(|_| Some(dir.path().join("the-new-name.rs")));
|
||||
|
||||
editor
|
||||
.condition(&cx, |editor, cx| !editor.is_dirty(cx))
|
||||
.await;
|
||||
|
||||
// The language is assigned based on the path
|
||||
editor.read_with(&cx, |editor, cx| {
|
||||
assert_eq!(editor.language(cx).unwrap().name(), "Rust")
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_new_empty_workspace(mut cx: gpui::TestAppContext) {
|
||||
cx.update(init);
|
||||
|
||||
Reference in New Issue
Block a user