mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Removed old experiments settings and staff mode flag, added new StaffMode global that is set based on the webserver's staff bit
This commit is contained in:
parent
ca2e0256e1
commit
ea39983f78
@ -8,4 +8,4 @@ crates/collab/static/styles.css
|
|||||||
vendor/bin
|
vendor/bin
|
||||||
assets/themes/*.json
|
assets/themes/*.json
|
||||||
assets/themes/internal/*.json
|
assets/themes/internal/*.json
|
||||||
assets/themes/experiments/*.json
|
assets/themes/staff/*.json
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,9 +7,8 @@
|
|||||||
/crates/collab/static/styles.css
|
/crates/collab/static/styles.css
|
||||||
/vendor/bin
|
/vendor/bin
|
||||||
/assets/themes/*.json
|
/assets/themes/*.json
|
||||||
/assets/themes/Internal/*.json
|
|
||||||
/assets/themes/Experiments/*.json
|
|
||||||
/assets/*licenses.md
|
/assets/*licenses.md
|
||||||
|
/assets/themes/staff/*.json
|
||||||
**/venv
|
**/venv
|
||||||
.build
|
.build
|
||||||
Packages
|
Packages
|
||||||
|
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6466,6 +6466,7 @@ dependencies = [
|
|||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
"theme",
|
"theme",
|
||||||
|
"util",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
25
README.md
25
README.md
@ -49,30 +49,9 @@ script/zed-with-local-servers --release
|
|||||||
|
|
||||||
If you trigger `cmd-alt-i`, Zed will copy a JSON representation of the current window contents to the clipboard. You can paste this in a tool like [DJSON](https://chrome.google.com/webstore/detail/djson-json-viewer-formatt/chaeijjekipecdajnijdldjjipaegdjc?hl=en) to navigate the state of on-screen elements in a structured way.
|
If you trigger `cmd-alt-i`, Zed will copy a JSON representation of the current window contents to the clipboard. You can paste this in a tool like [DJSON](https://chrome.google.com/webstore/detail/djson-json-viewer-formatt/chaeijjekipecdajnijdldjjipaegdjc?hl=en) to navigate the state of on-screen elements in a structured way.
|
||||||
|
|
||||||
### Staff Only Features
|
### Licensing
|
||||||
|
|
||||||
Many features (e.g. the terminal) take significant time and effort before they are polished enough to be released to even Alpha users. But Zed's team workflow relies on fast, daily PRs and there can be large merge conflicts for feature branchs that diverge for a few days. To bridge this gap, there is a `staff_mode` field in the Settings that staff can set to enable these unpolished or incomplete features. Note that this setting isn't leaked via autocompletion, but there is no mechanism to stop users from setting this anyway. As initilization of Zed components is only done once, on startup, setting `staff_mode` may require a restart to take effect. You can set staff only key bindings in the `assets/keymaps/internal.json` file, and add staff only themes in the `styles/src/themes/internal` directory
|
We use cargo-about to automatically comply with open source licenses. If CI is failing due to an unsupported license, first check whether this system is able to support this license type; ask a lawyer if you're unsure. Once you've verified the license, go to `script/licenses/zed-licenses.toml` and add the associated `accepted` SPDX identifier. If cargo about cannot find the license for the dependency at all, add a clarification field at the end of the file, as specified in the [cargo-about book](https://embarkstudios.github.io/cargo-about/cli/generate/config.html#crate-configuration).
|
||||||
|
|
||||||
### Experimental Features
|
|
||||||
|
|
||||||
A user facing feature flag can be added to Zed by:
|
|
||||||
|
|
||||||
* Adding a setting to the crates/settings/src/settings.rs FeatureFlags struct. Use a boolean for a simple on/off, or use a struct to experiment with different configuration options.
|
|
||||||
* If the feature needs keybindings, add a file to the `assets/keymaps/experiments/` folder, then update the `FeatureFlags::keymap_files()` method to check for your feature's flag and add it's keybindings's path to the method's list.
|
|
||||||
* If you want to add an experimental theme, add it to the `styles/src/themes/experiments` folder
|
|
||||||
|
|
||||||
The Settings global should be initialized with the user's feature flags by the time the feature's `init(cx)` equivalent is called.
|
|
||||||
|
|
||||||
To promote an experimental feature to a full feature:
|
|
||||||
|
|
||||||
* If this is an experimental theme, move the theme file from the `styles/src/themes/experiments` folder to the `styles/src/themes/` folder
|
|
||||||
* Take the features settings (if any) and add them under a new variable in the Settings struct. Don't forget to add a `merge()` call in `set_user_settings()`!
|
|
||||||
* Take the feature's keybindings and add them to the default.json (or equivalent) file
|
|
||||||
* Remove the file from the `FeatureFlags::keymap_files()` method
|
|
||||||
* Remove the conditional in the feature's `init(cx)` equivalent.
|
|
||||||
|
|
||||||
|
|
||||||
That's it 😸
|
|
||||||
|
|
||||||
### Wasm Plugins
|
### Wasm Plugins
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
[]
|
|
@ -7,7 +7,7 @@ use postage::{sink::Sink, watch};
|
|||||||
use rpc::proto::{RequestMessage, UsersResponse};
|
use rpc::proto::{RequestMessage, UsersResponse};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use util::TryFutureExt as _;
|
use util::{paths::StaffMode, TryFutureExt as _};
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
@ -148,6 +148,15 @@ impl UserStore {
|
|||||||
cx.read(|cx| cx.global::<Settings>().telemetry()),
|
cx.read(|cx| cx.global::<Settings>().telemetry()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cx.update(|cx| {
|
||||||
|
cx.update_global::<StaffMode, _, _>(|staff_mode, _| {
|
||||||
|
*staff_mode = info
|
||||||
|
.as_ref()
|
||||||
|
.map(|info| StaffMode(info.staff))
|
||||||
|
.unwrap_or(StaffMode(false));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
current_user_tx.send(user).await.ok();
|
current_user_tx.send(user).await.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use client::{
|
|||||||
EstablishConnectionError, UserStore,
|
EstablishConnectionError, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use fs::{FakeFs, HomeDir};
|
use fs::FakeFs;
|
||||||
use futures::{channel::oneshot, StreamExt as _};
|
use futures::{channel::oneshot, StreamExt as _};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
executor::Deterministic, test::EmptyView, ModelHandle, Task, TestAppContext, ViewHandle,
|
executor::Deterministic, test::EmptyView, ModelHandle, Task, TestAppContext, ViewHandle,
|
||||||
@ -100,7 +100,6 @@ impl TestServer {
|
|||||||
|
|
||||||
async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient {
|
async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()));
|
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ use smol::io::{AsyncReadExt, AsyncWriteExt};
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::Deref;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
io,
|
||||||
@ -94,16 +93,6 @@ impl LineEnding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HomeDir(pub PathBuf);
|
|
||||||
|
|
||||||
impl Deref for HomeDir {
|
|
||||||
type Target = PathBuf;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait Fs: Send + Sync {
|
pub trait Fs: Send + Sync {
|
||||||
async fn create_dir(&self, path: &Path) -> Result<()>;
|
async fn create_dir(&self, path: &Path) -> Result<()>;
|
||||||
|
@ -550,7 +550,6 @@ impl Project {
|
|||||||
if !cx.read(|cx| cx.has_global::<Settings>()) {
|
if !cx.read(|cx| cx.has_global::<Settings>()) {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()))
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use client::{proto, Client};
|
use client::{proto, Client};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{HashMap, VecDeque};
|
use collections::{HashMap, VecDeque};
|
||||||
|
use fs::LineEnding;
|
||||||
use fs::{repository::GitRepository, Fs};
|
use fs::{repository::GitRepository, Fs};
|
||||||
use fs::{HomeDir, LineEnding};
|
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{
|
channel::{
|
||||||
mpsc::{self, UnboundedSender},
|
mpsc::{self, UnboundedSender},
|
||||||
@ -49,6 +49,7 @@ use std::{
|
|||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap, TreeSet};
|
use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap, TreeSet};
|
||||||
|
use util::paths::HOME;
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
|
||||||
@ -1831,9 +1832,9 @@ impl language::File for File {
|
|||||||
} else {
|
} else {
|
||||||
let path = worktree.abs_path();
|
let path = worktree.abs_path();
|
||||||
|
|
||||||
if worktree.is_local() && path.starts_with(cx.global::<HomeDir>().as_path()) {
|
if worktree.is_local() && path.starts_with(HOME.as_path()) {
|
||||||
full_path.push("~");
|
full_path.push("~");
|
||||||
full_path.push(path.strip_prefix(cx.global::<HomeDir>().as_path()).unwrap());
|
full_path.push(path.strip_prefix(HOME.as_path()).unwrap());
|
||||||
} else {
|
} else {
|
||||||
full_path.push(path)
|
full_path.push(path)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{parse_json_with_comments, Settings};
|
use crate::parse_json_with_comments;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use assets::Assets;
|
use assets::Assets;
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
@ -42,16 +42,7 @@ struct ActionWithData(Box<str>, Box<RawValue>);
|
|||||||
|
|
||||||
impl KeymapFileContent {
|
impl KeymapFileContent {
|
||||||
pub fn load_defaults(cx: &mut MutableAppContext) {
|
pub fn load_defaults(cx: &mut MutableAppContext) {
|
||||||
let settings = cx.global::<Settings>();
|
for path in ["keymaps/default.json", "keymaps/vim.json"] {
|
||||||
let mut paths = vec!["keymaps/default.json", "keymaps/vim.json"];
|
|
||||||
|
|
||||||
if settings.staff_mode {
|
|
||||||
paths.push("keymaps/internal.json")
|
|
||||||
}
|
|
||||||
|
|
||||||
paths.extend(settings.experiments.keymap_files());
|
|
||||||
|
|
||||||
for path in paths {
|
|
||||||
Self::load(path, cx).unwrap();
|
Self::load(path, cx).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ pub use keymap_file::{keymap_file_json_schema, KeymapFileContent};
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub experiments: FeatureFlags,
|
|
||||||
pub buffer_font_family: FamilyId,
|
pub buffer_font_family: FamilyId,
|
||||||
pub default_buffer_font_size: f32,
|
pub default_buffer_font_size: f32,
|
||||||
pub buffer_font_size: f32,
|
pub buffer_font_size: f32,
|
||||||
@ -53,7 +52,6 @@ pub struct Settings {
|
|||||||
pub theme: Arc<Theme>,
|
pub theme: Arc<Theme>,
|
||||||
pub telemetry_defaults: TelemetrySettings,
|
pub telemetry_defaults: TelemetrySettings,
|
||||||
pub telemetry_overrides: TelemetrySettings,
|
pub telemetry_overrides: TelemetrySettings,
|
||||||
pub staff_mode: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
@ -71,17 +69,6 @@ impl TelemetrySettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub struct FeatureFlags {
|
|
||||||
pub experimental_themes: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FeatureFlags {
|
|
||||||
pub fn keymap_files(&self) -> Vec<&'static str> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct GitSettings {
|
pub struct GitSettings {
|
||||||
pub git_gutter: Option<GitGutter>,
|
pub git_gutter: Option<GitGutter>,
|
||||||
@ -283,7 +270,6 @@ impl Column for DockAnchor {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct SettingsFileContent {
|
pub struct SettingsFileContent {
|
||||||
pub experiments: Option<FeatureFlags>,
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub projects_online_by_default: Option<bool>,
|
pub projects_online_by_default: Option<bool>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -323,8 +309,6 @@ pub struct SettingsFileContent {
|
|||||||
pub theme: Option<String>,
|
pub theme: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub telemetry: TelemetrySettings,
|
pub telemetry: TelemetrySettings,
|
||||||
#[serde(default)]
|
|
||||||
pub staff_mode: Option<bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
@ -352,7 +336,6 @@ impl Settings {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
experiments: FeatureFlags::default(),
|
|
||||||
buffer_font_family: font_cache
|
buffer_font_family: font_cache
|
||||||
.load_family(&[defaults.buffer_font_family.as_ref().unwrap()])
|
.load_family(&[defaults.buffer_font_family.as_ref().unwrap()])
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -388,7 +371,6 @@ impl Settings {
|
|||||||
theme: themes.get(&defaults.theme.unwrap()).unwrap(),
|
theme: themes.get(&defaults.theme.unwrap()).unwrap(),
|
||||||
telemetry_defaults: defaults.telemetry,
|
telemetry_defaults: defaults.telemetry,
|
||||||
telemetry_overrides: Default::default(),
|
telemetry_overrides: Default::default(),
|
||||||
staff_mode: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,8 +407,6 @@ impl Settings {
|
|||||||
);
|
);
|
||||||
merge(&mut self.vim_mode, data.vim_mode);
|
merge(&mut self.vim_mode, data.vim_mode);
|
||||||
merge(&mut self.autosave, data.autosave);
|
merge(&mut self.autosave, data.autosave);
|
||||||
merge(&mut self.experiments, data.experiments);
|
|
||||||
merge(&mut self.staff_mode, data.staff_mode);
|
|
||||||
merge(&mut self.default_dock_anchor, data.default_dock_anchor);
|
merge(&mut self.default_dock_anchor, data.default_dock_anchor);
|
||||||
|
|
||||||
// Ensure terminal font is loaded, so we can request it in terminal_element layout
|
// Ensure terminal font is loaded, so we can request it in terminal_element layout
|
||||||
@ -552,7 +532,6 @@ impl Settings {
|
|||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn test(cx: &gpui::AppContext) -> Settings {
|
pub fn test(cx: &gpui::AppContext) -> Settings {
|
||||||
Settings {
|
Settings {
|
||||||
experiments: FeatureFlags::default(),
|
|
||||||
buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(),
|
buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(),
|
||||||
buffer_font_size: 14.,
|
buffer_font_size: 14.,
|
||||||
active_pane_magnification: 1.,
|
active_pane_magnification: 1.,
|
||||||
@ -589,7 +568,6 @@ impl Settings {
|
|||||||
metrics: Some(true),
|
metrics: Some(true),
|
||||||
},
|
},
|
||||||
telemetry_overrides: Default::default(),
|
telemetry_overrides: Default::default(),
|
||||||
staff_mode: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,8 +625,6 @@ pub fn settings_file_json_schema(
|
|||||||
]);
|
]);
|
||||||
let root_schema_object = &mut root_schema.schema.object.as_mut().unwrap();
|
let root_schema_object = &mut root_schema.schema.object.as_mut().unwrap();
|
||||||
|
|
||||||
// Avoid automcomplete for non-user facing settings
|
|
||||||
root_schema_object.properties.remove("staff_mode");
|
|
||||||
root_schema_object.properties.extend([
|
root_schema_object.properties.extend([
|
||||||
(
|
(
|
||||||
"theme".to_owned(),
|
"theme".to_owned(),
|
||||||
|
@ -22,20 +22,13 @@ impl ThemeRegistry {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list(&self, internal: bool, experiments: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
|
pub fn list(&self, staff: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
|
||||||
let mut dirs = self.assets.list("themes/");
|
let mut dirs = self.assets.list("themes/");
|
||||||
|
|
||||||
if !internal {
|
if !staff {
|
||||||
dirs = dirs
|
dirs = dirs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|path| !path.starts_with("themes/Internal"))
|
.filter(|path| !path.starts_with("themes/staff"))
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !experiments {
|
|
||||||
dirs = dirs
|
|
||||||
.into_iter()
|
|
||||||
.filter(|path| !path.starts_with("themes/Experiments"))
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ picker = { path = "../picker" }
|
|||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
|
util = { path = "../util" }
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
postage = { version = "0.4.1", features = ["futures-traits"] }
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
|
@ -7,6 +7,7 @@ use picker::{Picker, PickerDelegate};
|
|||||||
use settings::{settings_file::SettingsFile, Settings};
|
use settings::{settings_file::SettingsFile, Settings};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use theme::{Theme, ThemeMeta, ThemeRegistry};
|
use theme::{Theme, ThemeMeta, ThemeRegistry};
|
||||||
|
use util::paths::StaffMode;
|
||||||
use workspace::{AppState, Workspace};
|
use workspace::{AppState, Workspace};
|
||||||
|
|
||||||
pub struct ThemeSelector {
|
pub struct ThemeSelector {
|
||||||
@ -44,10 +45,7 @@ impl ThemeSelector {
|
|||||||
let original_theme = settings.theme.clone();
|
let original_theme = settings.theme.clone();
|
||||||
|
|
||||||
let mut theme_names = registry
|
let mut theme_names = registry
|
||||||
.list(
|
.list(**cx.global::<StaffMode>())
|
||||||
settings.staff_mode,
|
|
||||||
settings.experiments.experimental_themes,
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
theme_names.sort_unstable_by(|a, b| {
|
theme_names.sort_unstable_by(|a, b| {
|
||||||
a.is_light
|
a.is_light
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
use std::path::PathBuf;
|
use std::{ops::Deref, path::PathBuf};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct StaffMode(pub bool);
|
||||||
|
|
||||||
|
impl Deref for StaffMode {
|
||||||
|
type Target = bool;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory");
|
pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory");
|
||||||
|
@ -349,9 +349,6 @@ pub struct AppState {
|
|||||||
impl AppState {
|
impl AppState {
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn test(cx: &mut MutableAppContext) -> Arc<Self> {
|
pub fn test(cx: &mut MutableAppContext) -> Arc<Self> {
|
||||||
use fs::HomeDir;
|
|
||||||
|
|
||||||
cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()));
|
|
||||||
let settings = Settings::test(cx);
|
let settings = Settings::test(cx);
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use isahc::{config::Configurable, Request};
|
|||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use project::{Fs, HomeDir};
|
use project::Fs;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::{
|
use settings::{
|
||||||
self, settings_file::SettingsFile, KeymapFileContent, Settings, SettingsFileContent,
|
self, settings_file::SettingsFile, KeymapFileContent, Settings, SettingsFileContent,
|
||||||
@ -39,7 +39,11 @@ use terminal_view::{get_working_directory, TerminalView};
|
|||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
||||||
use theme::ThemeRegistry;
|
use theme::ThemeRegistry;
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
use util::{
|
||||||
|
channel::RELEASE_CHANNEL,
|
||||||
|
paths::{self, StaffMode},
|
||||||
|
ResultExt, TryFutureExt,
|
||||||
|
};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
||||||
};
|
};
|
||||||
@ -104,7 +108,11 @@ fn main() {
|
|||||||
|
|
||||||
app.run(move |cx| {
|
app.run(move |cx| {
|
||||||
cx.set_global(*RELEASE_CHANNEL);
|
cx.set_global(*RELEASE_CHANNEL);
|
||||||
cx.set_global(HomeDir(paths::HOME.to_path_buf()));
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
cx.set_global(StaffMode(false));
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
cx.set_global(StaffMode(true));
|
||||||
|
|
||||||
let (settings_file_content, keymap_file) = cx.background().block(config_files).unwrap();
|
let (settings_file_content, keymap_file) = cx.background().block(config_files).unwrap();
|
||||||
|
|
||||||
|
@ -32,7 +32,11 @@ use serde::Deserialize;
|
|||||||
use serde_json::to_string_pretty;
|
use serde_json::to_string_pretty;
|
||||||
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
|
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
|
||||||
use std::{borrow::Cow, env, path::Path, str, sync::Arc};
|
use std::{borrow::Cow, env, path::Path, str, sync::Arc};
|
||||||
use util::{channel::ReleaseChannel, paths, ResultExt};
|
use util::{
|
||||||
|
channel::ReleaseChannel,
|
||||||
|
paths::{self, StaffMode},
|
||||||
|
ResultExt,
|
||||||
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
pub use workspace;
|
pub use workspace;
|
||||||
use workspace::{sidebar::SidebarSide, AppState, Workspace};
|
use workspace::{sidebar::SidebarSide, AppState, Workspace};
|
||||||
@ -297,14 +301,9 @@ pub fn initialize_workspace(
|
|||||||
cx.emit(workspace::Event::PaneAdded(workspace.active_pane().clone()));
|
cx.emit(workspace::Event::PaneAdded(workspace.active_pane().clone()));
|
||||||
cx.emit(workspace::Event::PaneAdded(workspace.dock_pane().clone()));
|
cx.emit(workspace::Event::PaneAdded(workspace.dock_pane().clone()));
|
||||||
|
|
||||||
let settings = cx.global::<Settings>();
|
|
||||||
|
|
||||||
let theme_names = app_state
|
let theme_names = app_state
|
||||||
.themes
|
.themes
|
||||||
.list(
|
.list(**cx.global::<StaffMode>())
|
||||||
settings.staff_mode,
|
|
||||||
settings.experiments.experimental_themes,
|
|
||||||
)
|
|
||||||
.map(|meta| meta.name)
|
.map(|meta| meta.name)
|
||||||
.collect();
|
.collect();
|
||||||
let language_names = app_state.languages.language_names();
|
let language_names = app_state.languages.language_names();
|
||||||
@ -1868,7 +1867,7 @@ mod tests {
|
|||||||
let settings = Settings::defaults(Assets, cx.font_cache(), &themes);
|
let settings = Settings::defaults(Assets, cx.font_cache(), &themes);
|
||||||
|
|
||||||
let mut has_default_theme = false;
|
let mut has_default_theme = false;
|
||||||
for theme_name in themes.list(false, false).map(|meta| meta.name) {
|
for theme_name in themes.list(false).map(|meta| meta.name) {
|
||||||
let theme = themes.get(&theme_name).unwrap();
|
let theme = themes.get(&theme_name).unwrap();
|
||||||
if theme.meta.name == settings.theme.meta.name {
|
if theme.meta.name == settings.theme.meta.name {
|
||||||
has_default_theme = true;
|
has_default_theme = true;
|
||||||
|
@ -2,7 +2,7 @@ import * as fs from "fs";
|
|||||||
import { tmpdir } from "os";
|
import { tmpdir } from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import colorSchemes, {
|
import colorSchemes, {
|
||||||
experimentalColorSchemes, internalColorSchemes
|
staffColorSchemes,
|
||||||
} from "./colorSchemes";
|
} from "./colorSchemes";
|
||||||
import app from "./styleTree/app";
|
import app from "./styleTree/app";
|
||||||
import { ColorScheme } from "./themes/common/colorScheme";
|
import { ColorScheme } from "./themes/common/colorScheme";
|
||||||
@ -10,8 +10,7 @@ import snakeCase from "./utils/snakeCase";
|
|||||||
|
|
||||||
const assetsDirectory = `${__dirname}/../../assets`
|
const assetsDirectory = `${__dirname}/../../assets`
|
||||||
const themeDirectory = `${assetsDirectory}/themes`;
|
const themeDirectory = `${assetsDirectory}/themes`;
|
||||||
const internalDirectory = `${themeDirectory}/Internal`;
|
const staffDirectory = `${themeDirectory}/staff`;
|
||||||
const experimentsDirectory = `${themeDirectory}/Experiments`;
|
|
||||||
|
|
||||||
const tempDirectory = fs.mkdtempSync(path.join(tmpdir(), "build-themes"));
|
const tempDirectory = fs.mkdtempSync(path.join(tmpdir(), "build-themes"));
|
||||||
|
|
||||||
@ -32,8 +31,7 @@ function clearThemes(themeDirectory: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearThemes(themeDirectory);
|
clearThemes(themeDirectory);
|
||||||
clearThemes(internalDirectory);
|
clearThemes(staffDirectory);
|
||||||
clearThemes(experimentsDirectory);
|
|
||||||
|
|
||||||
function writeThemes(colorSchemes: ColorScheme[], outputDirectory: string) {
|
function writeThemes(colorSchemes: ColorScheme[], outputDirectory: string) {
|
||||||
for (let colorScheme of colorSchemes) {
|
for (let colorScheme of colorSchemes) {
|
||||||
@ -49,5 +47,4 @@ function writeThemes(colorSchemes: ColorScheme[], outputDirectory: string) {
|
|||||||
|
|
||||||
// Write new themes to theme directory
|
// Write new themes to theme directory
|
||||||
writeThemes(colorSchemes, themeDirectory);
|
writeThemes(colorSchemes, themeDirectory);
|
||||||
writeThemes(internalColorSchemes, internalDirectory);
|
writeThemes(staffColorSchemes, staffDirectory);
|
||||||
writeThemes(experimentalColorSchemes, experimentsDirectory);
|
|
||||||
|
@ -8,8 +8,8 @@ export default colorSchemes;
|
|||||||
const schemeMeta: Meta[] = [];
|
const schemeMeta: Meta[] = [];
|
||||||
export { schemeMeta };
|
export { schemeMeta };
|
||||||
|
|
||||||
const internalColorSchemes: ColorScheme[] = [];
|
const staffColorSchemes: ColorScheme[] = [];
|
||||||
export { internalColorSchemes };
|
export { staffColorSchemes };
|
||||||
|
|
||||||
const experimentalColorSchemes: ColorScheme[] = [];
|
const experimentalColorSchemes: ColorScheme[] = [];
|
||||||
export { experimentalColorSchemes };
|
export { experimentalColorSchemes };
|
||||||
@ -37,12 +37,8 @@ function fillColorSchemes(themesPath: string, colorSchemes: ColorScheme[]) {
|
|||||||
|
|
||||||
fillColorSchemes(themes_directory, colorSchemes);
|
fillColorSchemes(themes_directory, colorSchemes);
|
||||||
fillColorSchemes(
|
fillColorSchemes(
|
||||||
path.resolve(`${themes_directory}/internal`),
|
path.resolve(`${themes_directory}/staff`),
|
||||||
internalColorSchemes
|
staffColorSchemes
|
||||||
);
|
|
||||||
fillColorSchemes(
|
|
||||||
path.resolve(`${themes_directory}/experiments`),
|
|
||||||
experimentalColorSchemes
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function fillMeta(themesPath: string, meta: Meta[]) {
|
function fillMeta(themesPath: string, meta: Meta[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user