theme: Remove unused staff
parameter for listing themes (#20077)
This PR removes the `staff` parameter for listing themes, as it was not used. Release Notes: - N/A
This commit is contained in:
parent
af9e7f1f96
commit
a960344301
11 changed files with 13 additions and 23 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -6371,7 +6371,6 @@ dependencies = [
|
||||||
"async-tar",
|
"async-tar",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"collections",
|
"collections",
|
||||||
"feature_flags",
|
|
||||||
"futures 0.3.30",
|
"futures 0.3.30",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
|
@ -12127,7 +12126,6 @@ name = "theme_selector"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"client",
|
"client",
|
||||||
"feature_flags",
|
|
||||||
"fs",
|
"fs",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"gpui",
|
"gpui",
|
||||||
|
|
|
@ -296,7 +296,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
["ERB", "Plain Text", "Ruby"]
|
["ERB", "Plain Text", "Ruby"]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
theme_registry.list_names(false),
|
theme_registry.list_names(),
|
||||||
[
|
[
|
||||||
"Monokai Dark",
|
"Monokai Dark",
|
||||||
"Monokai Light",
|
"Monokai Light",
|
||||||
|
@ -377,7 +377,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
assert_eq!(index.themes, expected_index.themes);
|
assert_eq!(index.themes, expected_index.themes);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
theme_registry.list_names(false),
|
theme_registry.list_names(),
|
||||||
[
|
[
|
||||||
"Gruvbox",
|
"Gruvbox",
|
||||||
"Monokai Dark",
|
"Monokai Dark",
|
||||||
|
@ -424,7 +424,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
["embedded_template".into(), "ruby".into()]
|
["embedded_template".into(), "ruby".into()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
theme_registry.list_names(false),
|
theme_registry.list_names(),
|
||||||
[
|
[
|
||||||
"Gruvbox",
|
"Gruvbox",
|
||||||
"Monokai Dark",
|
"Monokai Dark",
|
||||||
|
|
|
@ -38,7 +38,6 @@ async-compression.workspace = true
|
||||||
async-tar.workspace = true
|
async-tar.workspace = true
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
feature_flags.workspace = true
|
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
|
|
|
@ -3,7 +3,6 @@ use async_compression::futures::bufread::GzipDecoder;
|
||||||
use async_tar::Archive;
|
use async_tar::Archive;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use feature_flags::FeatureFlagAppExt;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{AppContext, AsyncAppContext};
|
use gpui::{AppContext, AsyncAppContext};
|
||||||
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
|
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
|
@ -77,13 +76,11 @@ impl JsonLspAdapter {
|
||||||
|
|
||||||
fn get_workspace_config(language_names: Vec<String>, cx: &mut AppContext) -> Value {
|
fn get_workspace_config(language_names: Vec<String>, cx: &mut AppContext) -> Value {
|
||||||
let action_names = cx.all_action_names();
|
let action_names = cx.all_action_names();
|
||||||
let staff_mode = cx.is_staff();
|
|
||||||
|
|
||||||
let font_names = &cx.text_system().all_font_names();
|
let font_names = &cx.text_system().all_font_names();
|
||||||
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
||||||
&SettingsJsonSchemaParams {
|
&SettingsJsonSchemaParams {
|
||||||
language_names: &language_names,
|
language_names: &language_names,
|
||||||
staff_mode,
|
|
||||||
font_names,
|
font_names,
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
|
|
|
@ -2,7 +2,6 @@ use schemars::schema::{ArrayValidation, InstanceType, RootSchema, Schema, Schema
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
pub struct SettingsJsonSchemaParams<'a> {
|
pub struct SettingsJsonSchemaParams<'a> {
|
||||||
pub staff_mode: bool,
|
|
||||||
pub language_names: &'a [String],
|
pub language_names: &'a [String],
|
||||||
pub font_names: &'a [String],
|
pub font_names: &'a [String],
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl RenderOnce for ThemeControl {
|
||||||
ContextMenu::build(cx, |mut menu, cx| {
|
ContextMenu::build(cx, |mut menu, cx| {
|
||||||
let theme_registry = <dyn ThemeRegistry>::global(cx);
|
let theme_registry = <dyn ThemeRegistry>::global(cx);
|
||||||
|
|
||||||
for theme in theme_registry.list_names(false) {
|
for theme in theme_registry.list_names() {
|
||||||
menu = menu.custom_entry(
|
menu = menu.custom_entry(
|
||||||
{
|
{
|
||||||
let theme = theme.clone();
|
let theme = theme.clone();
|
||||||
|
|
|
@ -39,10 +39,10 @@ impl Global for GlobalThemeRegistry {}
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait ThemeRegistry: Send + Sync + 'static {
|
pub trait ThemeRegistry: Send + Sync + 'static {
|
||||||
/// Returns the names of all themes in the registry.
|
/// Returns the names of all themes in the registry.
|
||||||
fn list_names(&self, _staff: bool) -> Vec<SharedString>;
|
fn list_names(&self) -> Vec<SharedString>;
|
||||||
|
|
||||||
/// Returns the metadata of all themes in the registry.
|
/// Returns the metadata of all themes in the registry.
|
||||||
fn list(&self, _staff: bool) -> Vec<ThemeMeta>;
|
fn list(&self) -> Vec<ThemeMeta>;
|
||||||
|
|
||||||
/// Returns the theme with the given name.
|
/// Returns the theme with the given name.
|
||||||
fn get(&self, name: &str) -> Result<Arc<Theme>>;
|
fn get(&self, name: &str) -> Result<Arc<Theme>>;
|
||||||
|
@ -171,13 +171,13 @@ impl Default for RealThemeRegistry {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl ThemeRegistry for RealThemeRegistry {
|
impl ThemeRegistry for RealThemeRegistry {
|
||||||
fn list_names(&self, _staff: bool) -> Vec<SharedString> {
|
fn list_names(&self) -> Vec<SharedString> {
|
||||||
let mut names = self.state.read().themes.keys().cloned().collect::<Vec<_>>();
|
let mut names = self.state.read().themes.keys().cloned().collect::<Vec<_>>();
|
||||||
names.sort();
|
names.sort();
|
||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(&self, _staff: bool) -> Vec<ThemeMeta> {
|
fn list(&self) -> Vec<ThemeMeta> {
|
||||||
self.state
|
self.state
|
||||||
.read()
|
.read()
|
||||||
.themes
|
.themes
|
||||||
|
@ -238,11 +238,11 @@ pub struct VoidThemeRegistry;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl ThemeRegistry for VoidThemeRegistry {
|
impl ThemeRegistry for VoidThemeRegistry {
|
||||||
fn list_names(&self, _staff: bool) -> Vec<SharedString> {
|
fn list_names(&self) -> Vec<SharedString> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(&self, _staff: bool) -> Vec<ThemeMeta> {
|
fn list(&self) -> Vec<ThemeMeta> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -711,7 +711,7 @@ impl settings::Settings for ThemeSettings {
|
||||||
) -> schemars::schema::RootSchema {
|
) -> schemars::schema::RootSchema {
|
||||||
let mut root_schema = generator.root_schema_for::<ThemeSettingsContent>();
|
let mut root_schema = generator.root_schema_for::<ThemeSettingsContent>();
|
||||||
let theme_names = <dyn ThemeRegistry>::global(cx)
|
let theme_names = <dyn ThemeRegistry>::global(cx)
|
||||||
.list_names(params.staff_mode)
|
.list_names()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|theme_name| Value::String(theme_name.to_string()))
|
.map(|theme_name| Value::String(theme_name.to_string()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -14,7 +14,6 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
client.workspace = true
|
client.workspace = true
|
||||||
feature_flags.workspace = true
|
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
fuzzy.workspace = true
|
fuzzy.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use client::telemetry::Telemetry;
|
use client::telemetry::Telemetry;
|
||||||
use feature_flags::FeatureFlagAppExt;
|
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
|
@ -96,10 +95,9 @@ impl ThemeSelectorDelegate {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let original_theme = cx.theme().clone();
|
let original_theme = cx.theme().clone();
|
||||||
|
|
||||||
let staff_mode = cx.is_staff();
|
|
||||||
let registry = <dyn ThemeRegistry>::global(cx);
|
let registry = <dyn ThemeRegistry>::global(cx);
|
||||||
let mut themes = registry
|
let mut themes = registry
|
||||||
.list(staff_mode)
|
.list()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|meta| {
|
.filter(|meta| {
|
||||||
if let Some(theme_filter) = themes_filter {
|
if let Some(theme_filter) = themes_filter {
|
||||||
|
|
|
@ -3424,7 +3424,7 @@ mod tests {
|
||||||
theme::init(theme::LoadThemes::JustBase, cx);
|
theme::init(theme::LoadThemes::JustBase, cx);
|
||||||
|
|
||||||
let mut has_default_theme = false;
|
let mut has_default_theme = false;
|
||||||
for theme_name in themes.list(false).into_iter().map(|meta| meta.name) {
|
for theme_name in themes.list().into_iter().map(|meta| meta.name) {
|
||||||
let theme = themes.get(&theme_name).unwrap();
|
let theme = themes.get(&theme_name).unwrap();
|
||||||
assert_eq!(theme.name, theme_name);
|
assert_eq!(theme.name, theme_name);
|
||||||
if theme.name == ThemeSettings::get(None, cx).active_theme.name {
|
if theme.name == ThemeSettings::get(None, cx).active_theme.name {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue