From 4b2c24dd8c9836deb973935a46db70cdff3c74b6 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Sun, 8 Oct 2023 20:07:59 -0400 Subject: [PATCH] Add enable vim mode checkbox to welcome screen --- Cargo.lock | 1 + crates/vim/src/vim.rs | 2 +- crates/welcome/Cargo.toml | 1 + crates/welcome/src/welcome.rs | 25 ++++++++++++++++++++++++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c57548057d..3c7affc76f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9665,6 +9665,7 @@ dependencies = [ "theme", "theme_selector", "util", + "vim", "workspace", ] diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index d27be2c54b..aad97c558e 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -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); diff --git a/crates/welcome/Cargo.toml b/crates/welcome/Cargo.toml index ea01f822a7..c7ad62f155 100644 --- a/crates/welcome/Cargo.toml +++ b/crates/welcome/Cargo.toml @@ -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 diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rs index 4d8df53a1b..a5d95429bd 100644 --- a/crates/welcome/src/welcome.rs +++ b/crates/welcome/src/welcome.rs @@ -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::(cx); + let vim_mode_setting = settings::get::(cx).0; enum Metrics {} enum Diagnostics {} @@ -144,6 +146,27 @@ impl View for WelcomePage { ) .with_child( Flex::column() + .with_child( + theme::ui::checkbox::( + "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::( + fs, + cx, + move |setting| *setting = Some(checked), + ) + } + }, + ) + .contained() + .with_style(theme.welcome.checkbox_container), + ) .with_child( theme::ui::checkbox_with_label::( 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) {