mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Add enable vim mode checkbox to welcome screen
This commit is contained in:
parent
9f32a6e209
commit
4b2c24dd8c
4 changed files with 27 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -9665,6 +9665,7 @@ dependencies = [
|
|||
"theme",
|
||||
"theme_selector",
|
||||
"util",
|
||||
"vim",
|
||||
"workspace",
|
||||
]
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ use workspace::{self, Workspace};
|
|||
|
||||
use crate::state::ReplayableAction;
|
||||
|
||||
struct VimModeSetting(bool);
|
||||
pub struct VimModeSetting(pub bool);
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
pub struct SwitchMode(pub Mode);
|
||||
|
|
|
@ -25,6 +25,7 @@ theme_selector = { path = "../theme_selector" }
|
|||
util = { path = "../util" }
|
||||
picker = { path = "../picker" }
|
||||
workspace = { path = "../workspace" }
|
||||
vim = { path = "../vim" }
|
||||
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
|
|
|
@ -10,6 +10,7 @@ use gpui::{
|
|||
};
|
||||
use settings::{update_settings_file, SettingsStore};
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
use vim::VimModeSetting;
|
||||
use workspace::{
|
||||
dock::DockPosition, item::Item, open_new, AppState, PaneBackdrop, Welcome, Workspace,
|
||||
WorkspaceId,
|
||||
|
@ -65,6 +66,7 @@ impl View for WelcomePage {
|
|||
let width = theme.welcome.page_width;
|
||||
|
||||
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||
let vim_mode_setting = settings::get::<VimModeSetting>(cx).0;
|
||||
|
||||
enum Metrics {}
|
||||
enum Diagnostics {}
|
||||
|
@ -144,6 +146,27 @@ impl View for WelcomePage {
|
|||
)
|
||||
.with_child(
|
||||
Flex::column()
|
||||
.with_child(
|
||||
theme::ui::checkbox::<Diagnostics, Self, _>(
|
||||
"Enable vim mode",
|
||||
&theme.welcome.checkbox,
|
||||
vim_mode_setting,
|
||||
0,
|
||||
cx,
|
||||
|this, checked, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
let fs = workspace.read(cx).app_state().fs.clone();
|
||||
update_settings_file::<VimModeSetting>(
|
||||
fs,
|
||||
cx,
|
||||
move |setting| *setting = Some(checked),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox_container),
|
||||
)
|
||||
.with_child(
|
||||
theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
|
||||
Flex::column()
|
||||
|
@ -186,7 +209,7 @@ impl View for WelcomePage {
|
|||
"Send crash reports",
|
||||
&theme.welcome.checkbox,
|
||||
telemetry_settings.diagnostics,
|
||||
0,
|
||||
1,
|
||||
cx,
|
||||
|this, checked, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
|
|
Loading…
Reference in a new issue