Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

component_preview: Fix example rendering no text or icons (#59241)

Sergei G.f9d57b54dcbc
diff --git a/Cargo.lock b/Cargo.lock
index 2641cecc89e..7cb6bd19a42 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3621,10 +3621,13 @@ name = "component_preview"
version = "0.1.0"
dependencies = [
"anyhow",
+ "assets",
"client",
"collections",
"component",
"db",
+ "editor",
+ "env_logger 0.11.8",
"fs",
"gpui",
"gpui_platform",
diff --git a/crates/component_preview/Cargo.toml b/crates/component_preview/Cargo.toml
index 4a3cde33631..f6aeeefdc26 100644
--- a/crates/component_preview/Cargo.toml
+++ b/crates/component_preview/Cargo.toml
@@ -40,7 +40,10 @@ uuid.workspace = true
workspace.workspace = true
[dev-dependencies]
-gpui_platform = { workspace = true, features = ["screen-capture"] }
+assets.workspace = true
+editor.workspace = true
+env_logger.workspace = true
+gpui_platform = { workspace = true, features = ["screen-capture", "font-kit", "wayland", "x11"] }
[[example]]
name = "component_preview"
diff --git a/crates/component_preview/examples/component_preview.rs b/crates/component_preview/examples/component_preview.rs
index 8deaff1a8a6..a65821d0717 100644
--- a/crates/component_preview/examples/component_preview.rs
+++ b/crates/component_preview/examples/component_preview.rs
@@ -1,6 +1,7 @@
//! Component Preview Example
//!
//! Run with: `cargo run -p component_preview --example component_preview"`
+use assets::Assets;
use fs::RealFs;
use gpui::{AppContext as _, Bounds, KeyBinding, WindowBounds, WindowOptions, actions, size};
@@ -16,20 +17,28 @@ use workspace::{AppState, Workspace, WorkspaceStore};
use component_preview::{ComponentPreview, init};
-actions!(zed, [Quit]);
+actions!(component_preview, [Quit]);
fn quit(_: &Quit, cx: &mut App) {
cx.quit();
}
fn main() {
- gpui_platform::application().run(|cx| {
+ env_logger::builder()
+ .filter_level(log::LevelFilter::Warn)
+ .init();
+
+ gpui_platform::application().with_assets(Assets).run(|cx| {
component::init();
cx.on_action(quit);
cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]);
let version = release_channel::AppVersion::load(env!("CARGO_PKG_VERSION"), None, None);
release_channel::init(version, cx);
+ cx.set_global(db::AppDatabase::new());
+ Assets
+ .load_fonts(cx)
+ .expect("Failed to load embedded fonts");
let http_client =
ReqwestClient::user_agent("component_preview").expect("Failed to create HTTP client");
@@ -68,6 +77,7 @@ fn main() {
AppState::set_global(app_state.clone(), cx);
workspace::init(app_state.clone(), cx);
+ editor::init(cx);
init(app_state.clone(), cx);
let size = size(px(1200.), px(800.));