mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 19:25:33 +03:00
Add enable vim mode checkbox to welcome screen (#3105)
Had a user state that they didn't know how to enable vim mode and that it was "almost a non-starter" for them. IMO, it is a big enough feature to warrant being on the welcome screen. <img width="968" alt="SCR-20231008-rnhj" src="https://github.com/zed-industries/zed/assets/19867440/a189c646-1fa7-497c-b6d9-37cb1caa0492"> Release Notes: - Added an `Enable vim mode` checkbox to the welcome screen
This commit is contained in:
commit
77a932fe3b
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -9665,6 +9665,7 @@ dependencies = [
|
|||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"util",
|
"util",
|
||||||
|
"vim",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ use workspace::{self, Workspace};
|
|||||||
|
|
||||||
use crate::state::ReplayableAction;
|
use crate::state::ReplayableAction;
|
||||||
|
|
||||||
struct VimModeSetting(bool);
|
pub struct VimModeSetting(pub bool);
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, PartialEq)]
|
#[derive(Clone, Deserialize, PartialEq)]
|
||||||
pub struct SwitchMode(pub Mode);
|
pub struct SwitchMode(pub Mode);
|
||||||
|
@ -25,6 +25,7 @@ theme_selector = { path = "../theme_selector" }
|
|||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
picker = { path = "../picker" }
|
picker = { path = "../picker" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
|
vim = { path = "../vim" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
@ -10,6 +10,7 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use settings::{update_settings_file, SettingsStore};
|
use settings::{update_settings_file, SettingsStore};
|
||||||
use std::{borrow::Cow, sync::Arc};
|
use std::{borrow::Cow, sync::Arc};
|
||||||
|
use vim::VimModeSetting;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::DockPosition, item::Item, open_new, AppState, PaneBackdrop, Welcome, Workspace,
|
dock::DockPosition, item::Item, open_new, AppState, PaneBackdrop, Welcome, Workspace,
|
||||||
WorkspaceId,
|
WorkspaceId,
|
||||||
@ -65,6 +66,7 @@ impl View for WelcomePage {
|
|||||||
let width = theme.welcome.page_width;
|
let width = theme.welcome.page_width;
|
||||||
|
|
||||||
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||||
|
let vim_mode_setting = settings::get::<VimModeSetting>(cx).0;
|
||||||
|
|
||||||
enum Metrics {}
|
enum Metrics {}
|
||||||
enum Diagnostics {}
|
enum Diagnostics {}
|
||||||
@ -144,6 +146,27 @@ impl View for WelcomePage {
|
|||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Flex::column()
|
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(
|
.with_child(
|
||||||
theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
|
theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
|
||||||
Flex::column()
|
Flex::column()
|
||||||
@ -186,7 +209,7 @@ impl View for WelcomePage {
|
|||||||
"Send crash reports",
|
"Send crash reports",
|
||||||
&theme.welcome.checkbox,
|
&theme.welcome.checkbox,
|
||||||
telemetry_settings.diagnostics,
|
telemetry_settings.diagnostics,
|
||||||
0,
|
1,
|
||||||
cx,
|
cx,
|
||||||
|this, checked, cx| {
|
|this, checked, cx| {
|
||||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user