mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Revert "Basic feature flag implementation"
This commit is contained in:
parent
1b414b698f
commit
b6785c5624
5 changed files with 18 additions and 29 deletions
|
@ -425,5 +425,12 @@
|
||||||
"cmd-v": "terminal::Paste",
|
"cmd-v": "terminal::Paste",
|
||||||
"cmd-k": "terminal::Clear"
|
"cmd-k": "terminal::Clear"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"context": "ModalTerminal",
|
||||||
|
"bindings": {
|
||||||
|
"ctrl-cmd-space": "terminal::ShowCharacterPalette",
|
||||||
|
"shift-escape": "terminal::DeployModal"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -10,7 +10,6 @@ use schemars::{
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{value::RawValue, Value};
|
use serde_json::{value::RawValue, Value};
|
||||||
use util::ResultExt;
|
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Clone, JsonSchema)]
|
#[derive(Deserialize, Default, Clone, JsonSchema)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
|
@ -57,27 +56,26 @@ impl KeymapFileContent {
|
||||||
for KeymapBlock { context, bindings } in self.0 {
|
for KeymapBlock { context, bindings } in self.0 {
|
||||||
let bindings = bindings
|
let bindings = bindings
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|(keystroke, action)| {
|
.map(|(keystroke, action)| {
|
||||||
let action = action.0.get();
|
let action = action.0.get();
|
||||||
|
|
||||||
// This is a workaround for a limitation in serde: serde-rs/json#497
|
// This is a workaround for a limitation in serde: serde-rs/json#497
|
||||||
// We want to deserialize the action data as a `RawValue` so that we can
|
// We want to deserialize the action data as a `RawValue` so that we can
|
||||||
// deserialize the action itself dynamically directly from the JSON
|
// deserialize the action itself dynamically directly from the JSON
|
||||||
// string. But `RawValue` currently does not work inside of an untagged enum.
|
// string. But `RawValue` currently does not work inside of an untagged enum.
|
||||||
if action.starts_with('[') {
|
let action = if action.starts_with('[') {
|
||||||
let ActionWithData(name, data) = serde_json::from_str(action).log_err()?;
|
let ActionWithData(name, data) = serde_json::from_str(action)?;
|
||||||
cx.deserialize_action(&name, Some(data.get()))
|
cx.deserialize_action(&name, Some(data.get()))
|
||||||
} else {
|
} else {
|
||||||
let name = serde_json::from_str(action).log_err()?;
|
let name = serde_json::from_str(action)?;
|
||||||
cx.deserialize_action(name, None)
|
cx.deserialize_action(name, None)
|
||||||
}
|
}
|
||||||
.with_context(|| {
|
.with_context(|| {
|
||||||
format!(
|
format!(
|
||||||
"invalid binding value for keystroke {keystroke}, context {context:?}"
|
"invalid binding value for keystroke {keystroke}, context {context:?}"
|
||||||
)
|
)
|
||||||
})
|
})?;
|
||||||
.log_err()
|
Binding::load(&keystroke, action, context.as_deref())
|
||||||
.map(|action| Binding::load(&keystroke, action, context.as_deref()))
|
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ pub use keymap_file::{keymap_file_json_schema, KeymapFileContent};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub experiments: FeatureFlags,
|
|
||||||
pub projects_online_by_default: bool,
|
pub projects_online_by_default: bool,
|
||||||
pub buffer_font_family: FamilyId,
|
pub buffer_font_family: FamilyId,
|
||||||
pub default_buffer_font_size: f32,
|
pub default_buffer_font_size: f32,
|
||||||
|
@ -39,11 +38,6 @@ pub struct Settings {
|
||||||
pub theme: Arc<Theme>,
|
pub theme: Arc<Theme>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Deserialize, JsonSchema)]
|
|
||||||
pub struct FeatureFlags {
|
|
||||||
pub modal_terminal: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
|
||||||
pub struct EditorSettings {
|
pub struct EditorSettings {
|
||||||
pub tab_size: Option<NonZeroU32>,
|
pub tab_size: Option<NonZeroU32>,
|
||||||
|
@ -145,8 +139,6 @@ pub enum WorkingDirectory {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
|
||||||
pub struct SettingsFileContent {
|
pub struct SettingsFileContent {
|
||||||
#[serde(default)]
|
|
||||||
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)]
|
||||||
|
@ -197,7 +189,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(),
|
||||||
|
@ -256,7 +247,7 @@ 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);
|
|
||||||
// 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
|
||||||
if let Some(terminal_font) = &data.terminal.font_family {
|
if let Some(terminal_font) = &data.terminal.font_family {
|
||||||
font_cache.load_family(&[terminal_font]).log_err();
|
font_cache.load_family(&[terminal_font]).log_err();
|
||||||
|
@ -317,7 +308,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.,
|
||||||
default_buffer_font_size: 14.,
|
default_buffer_font_size: 14.,
|
||||||
|
|
|
@ -46,10 +46,7 @@ use crate::mappings::{
|
||||||
|
|
||||||
///Initialize and register all of our action handlers
|
///Initialize and register all of our action handlers
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
let settings = cx.global::<Settings>();
|
cx.add_action(deploy_modal);
|
||||||
if settings.experiments.modal_terminal {
|
|
||||||
cx.add_action(deploy_modal);
|
|
||||||
}
|
|
||||||
|
|
||||||
terminal_view::init(cx);
|
terminal_view::init(cx);
|
||||||
connected_view::init(cx);
|
connected_view::init(cx);
|
||||||
|
|
|
@ -95,12 +95,6 @@ fn main() {
|
||||||
.spawn(languages::init(languages.clone(), cx.background().clone()));
|
.spawn(languages::init(languages.clone(), cx.background().clone()));
|
||||||
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
|
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
|
||||||
|
|
||||||
let (settings_file, keymap_file) = cx.background().block(config_files).unwrap();
|
|
||||||
|
|
||||||
//Make sure to load settings before initialization, so we know what features to toggle
|
|
||||||
watch_settings_file(default_settings, settings_file, themes.clone(), cx);
|
|
||||||
watch_keymap_file(keymap_file, cx);
|
|
||||||
|
|
||||||
context_menu::init(cx);
|
context_menu::init(cx);
|
||||||
project::Project::init(&client);
|
project::Project::init(&client);
|
||||||
client::Channel::init(&client);
|
client::Channel::init(&client);
|
||||||
|
@ -120,7 +114,10 @@ fn main() {
|
||||||
terminal::init(cx);
|
terminal::init(cx);
|
||||||
|
|
||||||
let db = cx.background().block(db);
|
let db = cx.background().block(db);
|
||||||
|
let (settings_file, keymap_file) = cx.background().block(config_files).unwrap();
|
||||||
|
|
||||||
|
watch_settings_file(default_settings, settings_file, themes.clone(), cx);
|
||||||
|
watch_keymap_file(keymap_file, cx);
|
||||||
cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx))
|
cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx))
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue