Fix vim toggle on welcome

Conrad Irwin created

Change summary

Cargo.lock                     |  1 +
crates/welcome2/Cargo.toml     |  2 +-
crates/welcome2/src/welcome.rs | 26 ++++++++++++--------------
3 files changed, 14 insertions(+), 15 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -11423,6 +11423,7 @@ dependencies = [
  "theme_selector2",
  "ui2",
  "util",
+ "vim2",
  "workspace2",
 ]
 

crates/welcome2/Cargo.toml 🔗

@@ -26,7 +26,7 @@ theme_selector = { package = "theme_selector2", path = "../theme_selector2" }
 util = { path = "../util" }
 picker = { package = "picker2", path = "../picker2" }
 workspace = { package = "workspace2", path = "../workspace2" }
-# vim = { package = "vim2", path = "../vim2" }
+vim = { package = "vim2", path = "../vim2" }
 
 anyhow.workspace = true
 log.workspace = true

crates/welcome2/src/welcome.rs 🔗

@@ -11,6 +11,7 @@ use gpui::{
 use settings::{Settings, SettingsStore};
 use std::sync::Arc;
 use ui::{prelude::*, Checkbox};
+use vim::VimModeSetting;
 use workspace::{
     dock::DockPosition,
     item::{Item, ItemEvent},
@@ -128,29 +129,26 @@ impl Render for WelcomePage {
                         .border_color(cx.theme().colors().border)
                         .rounded_md()
                         .child(
-                            // todo!("vim setting")
                             h_stack()
                                 .gap_2()
                                 .child(
                                     Checkbox::new(
                                         "enable-vim",
-                                        if false
-                                        /* VimSettings::get_global(cx).enabled */
-                                        {
+                                        if VimModeSetting::get_global(cx).0 {
                                             ui::Selection::Selected
                                         } else {
                                             ui::Selection::Unselected
                                         },
-                                    ),
-                                    // .on_click(cx.listener(
-                                    //     move |this, selection, cx| {
-                                    //         this.update_settings::<VimSettings>(
-                                    //             selection,
-                                    //             cx,
-                                    //             |settings, value| settings.enabled = value,
-                                    //         );
-                                    //     },
-                                    // )),
+                                    )
+                                    .on_click(cx.listener(
+                                        move |this, selection, cx| {
+                                            this.update_settings::<VimModeSetting>(
+                                                selection,
+                                                cx,
+                                                |setting, value| *setting = Some(value),
+                                            );
+                                        },
+                                    )),
                                 )
                                 .child(Label::new("Enable vim mode")),
                         )