mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-10 04:09:37 +00:00
Test language assignment when new buffers are saved
This commit is contained in:
parent
af99d0ef42
commit
9e6c54ba0c
2 changed files with 10 additions and 4 deletions
|
@ -801,6 +801,10 @@ impl Buffer {
|
||||||
cx.emit(Event::FileHandleChanged);
|
cx.emit(Event::FileHandleChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn language(&self) -> Option<&Arc<Language>> {
|
||||||
|
self.language.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_count(&self) -> usize {
|
pub fn parse_count(&self) -> usize {
|
||||||
self.parse_count
|
self.parse_count
|
||||||
}
|
}
|
||||||
|
|
|
@ -1476,7 +1476,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
cx.simulate_new_path_selection(|parent_dir| {
|
cx.simulate_new_path_selection(|parent_dir| {
|
||||||
assert_eq!(parent_dir, dir.path());
|
assert_eq!(parent_dir, dir.path());
|
||||||
Some(parent_dir.join("the-new-name"))
|
Some(parent_dir.join("the-new-name.rs"))
|
||||||
});
|
});
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
assert!(editor.is_dirty(cx));
|
assert!(editor.is_dirty(cx));
|
||||||
|
@ -1489,8 +1489,10 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
assert!(!editor.is_dirty(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!(editor.language(cx).is_some()));
|
||||||
|
|
||||||
// Edit the file and save it again. This time, there is no filename prompt.
|
// Edit the file and save it again. This time, there is no filename prompt.
|
||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
|
@ -1504,7 +1506,7 @@ mod tests {
|
||||||
editor
|
editor
|
||||||
.condition(&cx, |editor, cx| !editor.is_dirty(cx))
|
.condition(&cx, |editor, cx| !editor.is_dirty(cx))
|
||||||
.await;
|
.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
|
// Open the same newly-created file in another pane item. The new editor should reuse
|
||||||
// the same buffer.
|
// the same buffer.
|
||||||
|
@ -1512,7 +1514,7 @@ mod tests {
|
||||||
workspace.open_new_file(&OpenNew(app_state.clone()), cx);
|
workspace.open_new_file(&OpenNew(app_state.clone()), cx);
|
||||||
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
|
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
|
||||||
assert!(workspace
|
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());
|
.is_none());
|
||||||
});
|
});
|
||||||
let editor2 = workspace.update(&mut cx, |workspace, cx| {
|
let editor2 = workspace.update(&mut cx, |workspace, cx| {
|
||||||
|
|
Loading…
Reference in a new issue