Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion crates/zed/src/zed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use gpui::{
px, retain_all,
};
use image_viewer::ImageInfo;
use language::Capability;
use language_tools::lsp_tool::{self, LspTool};
use migrate::{MigrationBanner, MigrationEvent, MigrationNotification, MigrationType};
use migrator::{migrate_keymap, migrate_settings};
Expand Down Expand Up @@ -1764,7 +1765,11 @@ fn open_bundled_file(
workspace.with_local_workspace(window, cx, |workspace, window, cx| {
let project = workspace.project();
let buffer = project.update(cx, move |project, cx| {
project.create_local_buffer(text.as_ref(), language, cx)
let buffer = project.create_local_buffer(text.as_ref(), language, cx);
buffer.update(cx, |buffer, cx| {
buffer.set_capability(Capability::ReadOnly, cx);
});
buffer
});
let buffer =
cx.new(|cx| MultiBuffer::singleton(buffer, cx).with_title(title.into()));
Expand Down Expand Up @@ -4543,6 +4548,43 @@ mod tests {
assert!(has_default_theme);
}

#[gpui::test]
async fn test_bundled_files_editor(cx: &mut TestAppContext) {
let app_state = init_test(cx);
cx.update(init);

let project = Project::test(app_state.fs.clone(), [], cx).await;
let _window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx));

cx.update(|cx| {
cx.dispatch_action(&OpenDefaultSettings);
});
cx.run_until_parked();

assert_eq!(cx.read(|cx| cx.windows().len()), 1);

let workspace = cx.windows()[0].downcast::<Workspace>().unwrap();
let active_editor = workspace
.update(cx, |workspace, _, cx| {
workspace.active_item_as::<Editor>(cx)
})
.unwrap();
assert!(
active_editor.is_some(),
"Settings action should have opened an editor with the default file contents"
);

let active_editor = active_editor.unwrap();
assert!(
active_editor.read_with(cx, |editor, cx| editor.read_only(cx)),
"Default settings should be readonly"
);
assert!(
active_editor.read_with(cx, |editor, cx| editor.buffer().read(cx).read_only()),
"The underlying buffer should also be readonly for the shipped default settings"
);
}

#[gpui::test]
async fn test_bundled_languages(cx: &mut TestAppContext) {
env_logger::builder().is_test(true).try_init().ok();
Expand Down