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