mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Highlight languages as languages load
This commit is contained in:
parent
988f388165
commit
3e8b230567
3 changed files with 8 additions and 3 deletions
|
@ -319,6 +319,7 @@ pub struct LanguageRegistry {
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
subscription: RwLock<(watch::Sender<()>, watch::Receiver<()>)>,
|
subscription: RwLock<(watch::Sender<()>, watch::Receiver<()>)>,
|
||||||
|
theme: RwLock<Option<Arc<SyntaxTheme>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LanguageRegistry {
|
impl LanguageRegistry {
|
||||||
|
@ -332,6 +333,7 @@ impl LanguageRegistry {
|
||||||
login_shell_env_loaded: login_shell_env_loaded.shared(),
|
login_shell_env_loaded: login_shell_env_loaded.shared(),
|
||||||
lsp_binary_paths: Default::default(),
|
lsp_binary_paths: Default::default(),
|
||||||
subscription: RwLock::new(watch::channel()),
|
subscription: RwLock::new(watch::channel()),
|
||||||
|
theme: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,6 +343,9 @@ impl LanguageRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&self, language: Arc<Language>) {
|
pub fn add(&self, language: Arc<Language>) {
|
||||||
|
if let Some(theme) = self.theme.read().clone() {
|
||||||
|
language.set_theme(theme);
|
||||||
|
}
|
||||||
self.languages.write().push(language.clone());
|
self.languages.write().push(language.clone());
|
||||||
*self.subscription.write().0.borrow_mut() = ();
|
*self.subscription.write().0.borrow_mut() = ();
|
||||||
}
|
}
|
||||||
|
@ -350,6 +355,7 @@ impl LanguageRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_theme(&self, theme: Arc<SyntaxTheme>) {
|
pub fn set_theme(&self, theme: Arc<SyntaxTheme>) {
|
||||||
|
*self.theme.write() = Some(theme.clone());
|
||||||
for language in self.languages.read().iter() {
|
for language in self.languages.read().iter() {
|
||||||
language.set_theme(theme.clone());
|
language.set_theme(theme.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,8 +225,8 @@ fn main() {
|
||||||
cx.spawn({
|
cx.spawn({
|
||||||
let languages = languages.clone();
|
let languages = languages.clone();
|
||||||
|cx| async move {
|
|cx| async move {
|
||||||
init_languages.await;
|
// init_languages.await;
|
||||||
dbg!("all languages initialized, starting setting highlighting");
|
dbg!("not all languages initialized, but starting setting highlighting");
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
languages.set_theme(cx.global::<Settings>().theme.editor.syntax.clone())
|
languages.set_theme(cx.global::<Settings>().theme.editor.syntax.clone())
|
||||||
});
|
});
|
||||||
|
|
1
test.rs
1
test.rs
|
@ -1 +0,0 @@
|
||||||
const A: usize = 32;
|
|
Loading…
Reference in a new issue