1#![allow(unused_variables, dead_code, unused_mut)]
2// todo!() this is to make transition easier.
3
4// Allow binary to be called Zed for a nice application menu when running executable directly
5#![allow(non_snake_case)]
6
7use anyhow::{anyhow, Context as _, Result};
8use backtrace::Backtrace;
9use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
10use client::UserStore;
11use db::kvp::KEY_VALUE_STORE;
12use fs::RealFs;
13use futures::StreamExt;
14use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
15use isahc::{prelude::Configurable, Request};
16use language::LanguageRegistry;
17use log::LevelFilter;
18
19use node_runtime::RealNodeRuntime;
20use parking_lot::Mutex;
21use serde::{Deserialize, Serialize};
22use settings::{
23 default_settings, handle_keymap_file_changes, handle_settings_file_changes, watch_config_file,
24 Settings, SettingsStore,
25};
26use simplelog::ConfigBuilder;
27use smol::process::Command;
28use std::{
29 env,
30 ffi::OsStr,
31 fs::OpenOptions,
32 io::{IsTerminal, Write},
33 panic,
34 path::{Path, PathBuf},
35 sync::{
36 atomic::{AtomicU32, Ordering},
37 Arc,
38 },
39 thread,
40 time::{SystemTime, UNIX_EPOCH},
41};
42use theme::ActiveTheme;
43use util::{
44 async_maybe,
45 channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
46 http::{self, HttpClient},
47 paths, ResultExt,
48};
49use uuid::Uuid;
50use workspace::{AppState, WorkspaceStore};
51use zed2::{
52 build_window_options, ensure_only_instance, handle_cli_connection, initialize_workspace,
53 languages, Assets, IsOnlyInstance, OpenListener, OpenRequest,
54};
55
56mod open_listener;
57
58fn main() {
59 //TODO!(figure out what the linker issues are here)
60 // https://github.com/rust-lang/rust/issues/47384
61 // https://github.com/mmastrac/rust-ctor/issues/280
62 menu::unused();
63 let http = http::client();
64 init_paths();
65 init_logger();
66
67 if ensure_only_instance() != IsOnlyInstance::Yes {
68 return;
69 }
70
71 log::info!("========== starting zed ==========");
72 let app = App::production(Arc::new(Assets));
73
74 let installation_id = app.background_executor().block(installation_id()).ok();
75 let session_id = Uuid::new_v4().to_string();
76 init_panic_hook(&app, installation_id.clone(), session_id.clone());
77
78 let fs = Arc::new(RealFs);
79 let user_settings_file_rx = watch_config_file(
80 &app.background_executor(),
81 fs.clone(),
82 paths::SETTINGS.clone(),
83 );
84 let user_keymap_file_rx = watch_config_file(
85 &app.background_executor(),
86 fs.clone(),
87 paths::KEYMAP.clone(),
88 );
89
90 let login_shell_env_loaded = if stdout_is_a_pty() {
91 Task::ready(())
92 } else {
93 app.background_executor().spawn(async {
94 load_login_shell_environment().await.log_err();
95 })
96 };
97
98 let (listener, mut open_rx) = OpenListener::new();
99 let listener = Arc::new(listener);
100 let open_listener = listener.clone();
101 app.on_open_urls(move |urls, _| open_listener.open_urls(urls));
102 app.on_reopen(move |_cx| {
103 // todo!("workspace")
104 // if cx.has_global::<Weak<AppState>>() {
105 // if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {
106 // workspace::open_new(&app_state, cx, |workspace, cx| {
107 // Editor::new_file(workspace, &Default::default(), cx)
108 // })
109 // .detach();
110 // }
111 // }
112 });
113
114 app.run(move |cx| {
115 cx.set_global(*RELEASE_CHANNEL);
116 load_embedded_fonts(cx);
117
118 let mut store = SettingsStore::default();
119 store
120 .set_default_settings(default_settings().as_ref(), cx)
121 .unwrap();
122 cx.set_global(store);
123 handle_settings_file_changes(user_settings_file_rx, cx);
124 handle_keymap_file_changes(user_keymap_file_rx, cx);
125
126 let client = client::Client::new(http.clone(), cx);
127 let mut languages = LanguageRegistry::new(login_shell_env_loaded);
128 let copilot_language_server_id = languages.next_language_server_id();
129 languages.set_executor(cx.background_executor().clone());
130 languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
131 let languages = Arc::new(languages);
132 let node_runtime = RealNodeRuntime::new(http.clone());
133
134 language::init(cx);
135 languages::init(languages.clone(), node_runtime.clone(), cx);
136 let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
137 let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
138
139 cx.set_global(client.clone());
140
141 theme::init(cx);
142 // context_menu::init(cx);
143 project::Project::init(&client, cx);
144 client::init(&client, cx);
145 command_palette::init(cx);
146 language::init(cx);
147 editor::init(cx);
148 copilot::init(
149 copilot_language_server_id,
150 http.clone(),
151 node_runtime.clone(),
152 cx,
153 );
154 // assistant::init(cx);
155 // component_test::init(cx);
156
157 // cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
158 // cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
159 // .detach();
160 // watch_file_types(fs.clone(), cx);
161
162 languages.set_theme(cx.theme().clone());
163 // cx.observe_global::<SettingsStore, _>({
164 // let languages = languages.clone();
165 // move |cx| languages.set_theme(theme::current(cx).clone())
166 // })
167 // .detach();
168
169 // client.telemetry().start(installation_id, session_id, cx);
170
171 let app_state = Arc::new(AppState {
172 languages,
173 client: client.clone(),
174 user_store,
175 fs,
176 build_window_options,
177 initialize_workspace,
178 // background_actions: todo!("ask Mikayla"),
179 workspace_store,
180 node_runtime,
181 });
182 cx.set_global(Arc::downgrade(&app_state));
183
184 // audio::init(Assets, cx);
185 // auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);
186
187 workspace::init(app_state.clone(), cx);
188 // recent_projects::init(cx);
189
190 go_to_line::init(cx);
191 // file_finder::init(cx);
192 // outline::init(cx);
193 // project_symbols::init(cx);
194 // project_panel::init(Assets, cx);
195 // channel::init(&client, user_store.clone(), cx);
196 // diagnostics::init(cx);
197 // search::init(cx);
198 // semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
199 // vim::init(cx);
200 // terminal_view::init(cx);
201
202 // journal2::init(app_state.clone(), cx);
203 // language_selector::init(cx);
204 // theme_selector::init(cx);
205 // activity_indicator::init(cx);
206 // language_tools::init(cx);
207 call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
208 // collab_ui::init(&app_state, cx);
209 // feedback::init(cx);
210 // welcome::init(cx);
211 // zed::init(&app_state, cx);
212
213 // cx.set_menus(menus::menus());
214
215 if stdout_is_a_pty() {
216 cx.activate(true);
217 let urls = collect_url_args();
218 if !urls.is_empty() {
219 listener.open_urls(urls)
220 }
221 } else {
222 upload_previous_panics(http.clone(), cx);
223
224 // TODO Development mode that forces the CLI mode usually runs Zed binary as is instead
225 // of an *app, hence gets no specific callbacks run. Emulate them here, if needed.
226 if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
227 && !listener.triggered.load(Ordering::Acquire)
228 {
229 listener.open_urls(collect_url_args())
230 }
231 }
232
233 let mut _triggered_authentication = false;
234
235 fn open_paths_and_log_errs(
236 paths: &[PathBuf],
237 app_state: &Arc<AppState>,
238 cx: &mut AppContext,
239 ) {
240 let task = workspace::open_paths(&paths, &app_state, None, cx);
241 cx.spawn(|cx| async move {
242 if let Some((_window, results)) = task.await.log_err() {
243 for result in results {
244 if let Some(Err(e)) = result {
245 log::error!("Error opening path: {}", e);
246 }
247 }
248 }
249 })
250 .detach();
251 }
252
253 match open_rx.try_next() {
254 Ok(Some(OpenRequest::Paths { paths })) => {
255 open_paths_and_log_errs(&paths, &app_state, cx)
256 }
257 Ok(Some(OpenRequest::CliConnection { connection })) => {
258 let app_state = app_state.clone();
259 cx.spawn(move |cx| handle_cli_connection(connection, app_state, cx))
260 .detach();
261 }
262 Ok(Some(OpenRequest::JoinChannel { channel_id: _ })) => {
263 todo!()
264 // triggered_authentication = true;
265 // let app_state = app_state.clone();
266 // let client = client.clone();
267 // cx.spawn(|mut cx| async move {
268 // // ignore errors here, we'll show a generic "not signed in"
269 // let _ = authenticate(client, &cx).await;
270 // cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
271 // .await
272 // })
273 // .detach_and_log_err(cx)
274 }
275 Ok(Some(OpenRequest::OpenChannelNotes { channel_id: _ })) => {
276 todo!()
277 }
278 Ok(None) | Err(_) => cx
279 .spawn({
280 let app_state = app_state.clone();
281 |cx| async move { restore_or_create_workspace(&app_state, cx).await }
282 })
283 .detach(),
284 }
285
286 let app_state = app_state.clone();
287 cx.spawn(|cx| async move {
288 while let Some(request) = open_rx.next().await {
289 match request {
290 OpenRequest::Paths { paths } => {
291 cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx))
292 .ok();
293 }
294 OpenRequest::CliConnection { connection } => {
295 let app_state = app_state.clone();
296 cx.spawn(move |cx| {
297 handle_cli_connection(connection, app_state.clone(), cx)
298 })
299 .detach();
300 }
301 OpenRequest::JoinChannel { channel_id: _ } => {
302 todo!()
303 }
304 OpenRequest::OpenChannelNotes { channel_id: _ } => {
305 todo!()
306 }
307 }
308 }
309 })
310 .detach();
311
312 // if !triggered_authentication {
313 // cx.spawn(|cx| async move { authenticate(client, &cx).await })
314 // .detach_and_log_err(cx);
315 // }
316 });
317}
318
319// async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
320// if stdout_is_a_pty() {
321// if client::IMPERSONATE_LOGIN.is_some() {
322// client.authenticate_and_connect(false, &cx).await?;
323// }
324// } else if client.has_keychain_credentials(&cx) {
325// client.authenticate_and_connect(true, &cx).await?;
326// }
327// Ok::<_, anyhow::Error>(())
328// }
329
330async fn installation_id() -> Result<String> {
331 let legacy_key_name = "device_id";
332
333 if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
334 Ok(installation_id)
335 } else {
336 let installation_id = Uuid::new_v4().to_string();
337
338 KEY_VALUE_STORE
339 .write_kvp(legacy_key_name.to_string(), installation_id.clone())
340 .await?;
341
342 Ok(installation_id)
343 }
344}
345
346async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
347 async_maybe!({
348 if let Some(location) = workspace::last_opened_workspace_paths().await {
349 cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))?
350 .await
351 .log_err();
352 } else if matches!(KEY_VALUE_STORE.read_kvp("******* THIS IS A BAD KEY PLEASE UNCOMMENT BELOW TO FIX THIS VERY LONG LINE *******"), Ok(None)) {
353 // todo!(welcome)
354 //} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
355 //todo!()
356 // cx.update(|cx| show_welcome_experience(app_state, cx));
357 } else {
358 cx.update(|cx| {
359 workspace::open_new(app_state, cx, |workspace, cx| {
360 Editor::new_file(workspace, &Default::default(), cx)
361 })
362 .detach();
363 })?;
364 }
365 anyhow::Ok(())
366 })
367 .await
368 .log_err();
369}
370
371fn init_paths() {
372 std::fs::create_dir_all(&*util::paths::CONFIG_DIR).expect("could not create config path");
373 std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path");
374 std::fs::create_dir_all(&*util::paths::DB_DIR).expect("could not create database path");
375 std::fs::create_dir_all(&*util::paths::LOGS_DIR).expect("could not create logs path");
376}
377
378fn init_logger() {
379 if stdout_is_a_pty() {
380 env_logger::init();
381 } else {
382 let level = LevelFilter::Info;
383
384 // Prevent log file from becoming too large.
385 const KIB: u64 = 1024;
386 const MIB: u64 = 1024 * KIB;
387 const MAX_LOG_BYTES: u64 = MIB;
388 if std::fs::metadata(&*paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
389 {
390 let _ = std::fs::rename(&*paths::LOG, &*paths::OLD_LOG);
391 }
392
393 let log_file = OpenOptions::new()
394 .create(true)
395 .append(true)
396 .open(&*paths::LOG)
397 .expect("could not open logfile");
398
399 let config = ConfigBuilder::new()
400 .set_time_format_str("%Y-%m-%dT%T") //All timestamps are UTC
401 .build();
402
403 simplelog::WriteLogger::init(level, config, log_file).expect("could not initialize logger");
404 }
405}
406
407#[derive(Serialize, Deserialize)]
408struct LocationData {
409 file: String,
410 line: u32,
411}
412
413#[derive(Serialize, Deserialize)]
414struct Panic {
415 thread: String,
416 payload: String,
417 #[serde(skip_serializing_if = "Option::is_none")]
418 location_data: Option<LocationData>,
419 backtrace: Vec<String>,
420 app_version: String,
421 release_channel: String,
422 os_name: String,
423 os_version: Option<String>,
424 architecture: String,
425 panicked_on: u128,
426 #[serde(skip_serializing_if = "Option::is_none")]
427 installation_id: Option<String>,
428 session_id: String,
429}
430
431#[derive(Serialize)]
432struct PanicRequest {
433 panic: Panic,
434 token: String,
435}
436
437static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
438
439fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: String) {
440 let is_pty = stdout_is_a_pty();
441 let app_metadata = app.metadata();
442
443 panic::set_hook(Box::new(move |info| {
444 let prior_panic_count = PANIC_COUNT.fetch_add(1, Ordering::SeqCst);
445 if prior_panic_count > 0 {
446 // Give the panic-ing thread time to write the panic file
447 loop {
448 std::thread::yield_now();
449 }
450 }
451
452 let thread = thread::current();
453 let thread_name = thread.name().unwrap_or("<unnamed>");
454
455 let payload = info
456 .payload()
457 .downcast_ref::<&str>()
458 .map(|s| s.to_string())
459 .or_else(|| info.payload().downcast_ref::<String>().map(|s| s.clone()))
460 .unwrap_or_else(|| "Box<Any>".to_string());
461
462 if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
463 let location = info.location().unwrap();
464 let backtrace = Backtrace::new();
465 eprintln!(
466 "Thread {:?} panicked with {:?} at {}:{}:{}\n{:?}",
467 thread_name,
468 payload,
469 location.file(),
470 location.line(),
471 location.column(),
472 backtrace,
473 );
474 std::process::exit(-1);
475 }
476
477 let app_version = client::ZED_APP_VERSION
478 .or(app_metadata.app_version)
479 .map_or("dev".to_string(), |v| v.to_string());
480
481 let backtrace = Backtrace::new();
482 let mut backtrace = backtrace
483 .frames()
484 .iter()
485 .filter_map(|frame| Some(format!("{:#}", frame.symbols().first()?.name()?)))
486 .collect::<Vec<_>>();
487
488 // Strip out leading stack frames for rust panic-handling.
489 if let Some(ix) = backtrace
490 .iter()
491 .position(|name| name == "rust_begin_unwind")
492 {
493 backtrace.drain(0..=ix);
494 }
495
496 let panic_data = Panic {
497 thread: thread_name.into(),
498 payload: payload.into(),
499 location_data: info.location().map(|location| LocationData {
500 file: location.file().into(),
501 line: location.line(),
502 }),
503 app_version: app_version.clone(),
504 release_channel: RELEASE_CHANNEL.display_name().into(),
505 os_name: app_metadata.os_name.into(),
506 os_version: app_metadata
507 .os_version
508 .as_ref()
509 .map(SemanticVersion::to_string),
510 architecture: env::consts::ARCH.into(),
511 panicked_on: SystemTime::now()
512 .duration_since(UNIX_EPOCH)
513 .unwrap()
514 .as_millis(),
515 backtrace,
516 installation_id: installation_id.clone(),
517 session_id: session_id.clone(),
518 };
519
520 if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
521 log::error!("{}", panic_data_json);
522 }
523
524 if !is_pty {
525 if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
526 let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
527 let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
528 let panic_file = std::fs::OpenOptions::new()
529 .append(true)
530 .create(true)
531 .open(&panic_file_path)
532 .log_err();
533 if let Some(mut panic_file) = panic_file {
534 writeln!(&mut panic_file, "{}", panic_data_json).log_err();
535 panic_file.flush().log_err();
536 }
537 }
538 }
539
540 std::process::abort();
541 }));
542}
543
544fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
545 let telemetry_settings = *client::TelemetrySettings::get_global(cx);
546
547 cx.background_executor()
548 .spawn(async move {
549 let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
550 let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
551 while let Some(child) = children.next().await {
552 let child = child?;
553 let child_path = child.path();
554
555 if child_path.extension() != Some(OsStr::new("panic")) {
556 continue;
557 }
558 let filename = if let Some(filename) = child_path.file_name() {
559 filename.to_string_lossy()
560 } else {
561 continue;
562 };
563
564 if !filename.starts_with("zed") {
565 continue;
566 }
567
568 if telemetry_settings.diagnostics {
569 let panic_file_content = smol::fs::read_to_string(&child_path)
570 .await
571 .context("error reading panic file")?;
572
573 let panic = serde_json::from_str(&panic_file_content)
574 .ok()
575 .or_else(|| {
576 panic_file_content
577 .lines()
578 .next()
579 .and_then(|line| serde_json::from_str(line).ok())
580 })
581 .unwrap_or_else(|| {
582 log::error!(
583 "failed to deserialize panic file {:?}",
584 panic_file_content
585 );
586 None
587 });
588
589 if let Some(panic) = panic {
590 let body = serde_json::to_string(&PanicRequest {
591 panic,
592 token: client::ZED_SECRET_CLIENT_TOKEN.into(),
593 })
594 .unwrap();
595
596 let request = Request::post(&panic_report_url)
597 .redirect_policy(isahc::config::RedirectPolicy::Follow)
598 .header("Content-Type", "application/json")
599 .body(body.into())?;
600 let response = http.send(request).await.context("error sending panic")?;
601 if !response.status().is_success() {
602 log::error!("Error uploading panic to server: {}", response.status());
603 }
604 }
605 }
606
607 // We've done what we can, delete the file
608 std::fs::remove_file(child_path)
609 .context("error removing panic")
610 .log_err();
611 }
612 Ok::<_, anyhow::Error>(())
613 })
614 .detach_and_log_err(cx);
615}
616
617async fn load_login_shell_environment() -> Result<()> {
618 let marker = "ZED_LOGIN_SHELL_START";
619 let shell = env::var("SHELL").context(
620 "SHELL environment variable is not assigned so we can't source login environment variables",
621 )?;
622 let output = Command::new(&shell)
623 .args(["-lic", &format!("echo {marker} && /usr/bin/env -0")])
624 .output()
625 .await
626 .context("failed to spawn login shell to source login environment variables")?;
627 if !output.status.success() {
628 Err(anyhow!("login shell exited with error"))?;
629 }
630
631 let stdout = String::from_utf8_lossy(&output.stdout);
632
633 if let Some(env_output_start) = stdout.find(marker) {
634 let env_output = &stdout[env_output_start + marker.len()..];
635 for line in env_output.split_terminator('\0') {
636 if let Some(separator_index) = line.find('=') {
637 let key = &line[..separator_index];
638 let value = &line[separator_index + 1..];
639 env::set_var(key, value);
640 }
641 }
642 log::info!(
643 "set environment variables from shell:{}, path:{}",
644 shell,
645 env::var("PATH").unwrap_or_default(),
646 );
647 }
648
649 Ok(())
650}
651
652fn stdout_is_a_pty() -> bool {
653 std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
654}
655
656fn collect_url_args() -> Vec<String> {
657 env::args()
658 .skip(1)
659 .filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
660 Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
661 Err(error) => {
662 if let Some(_) = parse_zed_link(&arg) {
663 Some(arg)
664 } else {
665 log::error!("error parsing path argument: {}", error);
666 None
667 }
668 }
669 })
670 .collect()
671}
672
673fn load_embedded_fonts(cx: &AppContext) {
674 let asset_source = cx.asset_source();
675 let font_paths = asset_source.list("fonts").unwrap();
676 let embedded_fonts = Mutex::new(Vec::new());
677 let executor = cx.background_executor();
678
679 executor.block(executor.scoped(|scope| {
680 for font_path in &font_paths {
681 if !font_path.ends_with(".ttf") {
682 continue;
683 }
684
685 scope.spawn(async {
686 let font_bytes = asset_source.load(font_path).unwrap().to_vec();
687 embedded_fonts.lock().push(Arc::from(font_bytes));
688 });
689 }
690 }));
691
692 cx.text_system()
693 .add_fonts(&embedded_fonts.into_inner())
694 .unwrap();
695}
696
697// #[cfg(debug_assertions)]
698// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
699// let mut events = fs
700// .watch("styles/src".as_ref(), Duration::from_millis(100))
701// .await;
702// while (events.next().await).is_some() {
703// let output = Command::new("npm")
704// .current_dir("styles")
705// .args(["run", "build"])
706// .output()
707// .await
708// .log_err()?;
709// if output.status.success() {
710// cx.update(|cx| theme_selector::reload(cx))
711// } else {
712// eprintln!(
713// "build script failed {}",
714// String::from_utf8_lossy(&output.stderr)
715// );
716// }
717// }
718// Some(())
719// }
720
721// #[cfg(debug_assertions)]
722// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
723// let mut events = fs
724// .watch(
725// "crates/zed/src/languages".as_ref(),
726// Duration::from_millis(100),
727// )
728// .await;
729// while (events.next().await).is_some() {
730// languages.reload();
731// }
732// Some(())
733// }
734
735// #[cfg(debug_assertions)]
736// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
737// cx.spawn(|mut cx| async move {
738// let mut events = fs
739// .watch(
740// "assets/icons/file_icons/file_types.json".as_ref(),
741// Duration::from_millis(100),
742// )
743// .await;
744// while (events.next().await).is_some() {
745// cx.update(|cx| {
746// cx.update_global(|file_types, _| {
747// *file_types = project_panel::file_associations::FileAssociations::new(Assets);
748// });
749// })
750// }
751// })
752// .detach()
753// }
754
755// #[cfg(not(debug_assertions))]
756// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
757// None
758// }
759
760// #[cfg(not(debug_assertions))]
761// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
762// None
763//
764
765// #[cfg(not(debug_assertions))]
766// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
767
768pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
769 // &[
770 // ("Go to file", &file_finder::Toggle),
771 // ("Open command palette", &command_palette::Toggle),
772 // ("Open recent projects", &recent_projects::OpenRecent),
773 // ("Change your settings", &zed_actions::OpenSettings),
774 // ]
775 // todo!()
776 &[]
777}