feat: syntax highlighting for diff view

This commit is contained in:
2026-05-25 00:08:22 +01:00
parent b3e041a257
commit a6cf96ea96
20 changed files with 1295 additions and 722 deletions

View File

@@ -1,4 +1,4 @@
use gpui::{AppContext, BorrowAppContext};
use gpui::BorrowAppContext;
use std::{any::Any, borrow::Cow, collections::HashMap, marker::PhantomData, ops::Deref};
pub(crate) trait QueryFn: Clone + 'static {
@@ -187,19 +187,28 @@ where
}
}
pub fn observe_query<E, F>(
query: &Entity<F>,
mut on_notify: impl FnMut(&mut E, &Entity<F>, &mut gpui::Context<E>) + 'static,
cx: &mut gpui::Context<E>,
) -> gpui::Subscription
pub fn watch_query<E, F, H>(query: &Entity<F>, on_notify: H, cx: &mut gpui::Context<E>) -> gpui::Subscription
where
E: 'static,
F: QueryFn,
H: Fn(&mut E, &Entity<F>, &mut gpui::Context<E>) + Clone + 'static,
{
let q = query.clone();
cx.observe(&query, move |this, _, cx| {
on_notify(this, &q, cx);
let observed_query = query.clone();
let sub = cx.observe(query, {
let on_notify = on_notify.clone();
move |this, _, cx| on_notify(this, &observed_query, cx)
});
let initial_query = query.clone();
cx.spawn({
let on_notify = on_notify.clone();
async move |weak, cx| {
let _ = weak.update(cx, |this, cx| on_notify(this, &initial_query, cx));
}
})
.detach();
sub
}
// ================= Store ==================