Finish up ThemeRegistry and remove AnyAssetSource

This commit is contained in:
Marshall Bowers 2023-10-24 17:47:41 +02:00
parent 51c66f508b
commit 4ca7ddfc42
9 changed files with 39 additions and 51 deletions

View file

@ -13,16 +13,16 @@ use rust_embed::RustEmbed;
pub struct Assets;
impl AssetSource for Assets {
fn load(&self, path: &SharedString) -> Result<std::borrow::Cow<[u8]>> {
fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
Self::get(path)
.map(|f| f.data)
.ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
}
fn list(&self, path: &SharedString) -> Result<Vec<SharedString>> {
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
Ok(Self::iter()
.filter_map(|p| {
if p.starts_with(path.as_ref()) {
if p.starts_with(path) {
Some(p.into())
} else {
None

View file

@ -11,7 +11,7 @@ use cli::{
use db2::kvp::KEY_VALUE_STORE;
use fs::RealFs;
use futures::{channel::mpsc, SinkExt, StreamExt};
use gpui2::{App, AppContext, AssetSource, AsyncAppContext, SemanticVersion, Task};
use gpui2::{App, AppContext, AsyncAppContext, SemanticVersion, Task};
use isahc::{prelude::Configurable, Request};
use language2::LanguageRegistry;
use log::LevelFilter;