Fix crash when launching Zed.exe
directly from target/debug
dir (#9112)
As I described in #9111 , the PR fixs this crash. Release Notes: - N/A
This commit is contained in:
parent
a56a260778
commit
2abb5aeaf2
1 changed files with 9 additions and 26 deletions
|
@ -184,8 +184,6 @@ fn main() {
|
||||||
load_user_themes_in_background(fs.clone(), cx);
|
load_user_themes_in_background(fs.clone(), cx);
|
||||||
watch_themes(fs.clone(), cx);
|
watch_themes(fs.clone(), cx);
|
||||||
|
|
||||||
cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
|
|
||||||
.detach();
|
|
||||||
watch_file_types(fs.clone(), cx);
|
watch_file_types(fs.clone(), cx);
|
||||||
|
|
||||||
languages.set_theme(cx.theme().clone());
|
languages.set_theme(cx.theme().clone());
|
||||||
|
@ -1004,32 +1002,20 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||||
.detach()
|
.detach()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
async fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>) {
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
let reload_debounce = Duration::from_millis(250);
|
|
||||||
|
|
||||||
let mut events = fs
|
|
||||||
.watch("crates/zed/src/languages".as_ref(), reload_debounce)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
while (events.next().await).is_some() {
|
|
||||||
languages.reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
let path = {
|
||||||
|
let p = Path::new("assets/icons/file_icons/file_types.json");
|
||||||
|
let Ok(full_path) = p.canonicalize() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
full_path
|
||||||
|
};
|
||||||
|
|
||||||
cx.spawn(|cx| async move {
|
cx.spawn(|cx| async move {
|
||||||
let mut events = fs
|
let mut events = fs.watch(path.as_path(), Duration::from_millis(100)).await;
|
||||||
.watch(
|
|
||||||
"assets/icons/file_icons/file_types.json".as_ref(),
|
|
||||||
Duration::from_millis(100),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
while (events.next().await).is_some() {
|
while (events.next().await).is_some() {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.update_global(|file_types, _| {
|
cx.update_global(|file_types, _| {
|
||||||
|
@ -1044,6 +1030,3 @@ fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
fn watch_file_types(_fs: Arc<dyn fs::Fs>, _cx: &mut AppContext) {}
|
fn watch_file_types(_fs: Arc<dyn fs::Fs>, _cx: &mut AppContext) {}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
|
||||||
async fn watch_languages(_fs: Arc<dyn fs::Fs>, _languages: Arc<LanguageRegistry>) {}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue