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