Add more convert to case commands
ConvertToTitleCase ConvertToSnakeCase ConvertToKebabCase ConvertToUpperCamelCase ConvertToLowerCamelCase
This commit is contained in:
parent
5c2f38a0bc
commit
12e8f417e4
3 changed files with 51 additions and 1 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -1649,6 +1649,15 @@ dependencies = [
|
||||||
"theme",
|
"theme",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "copilot"
|
name = "copilot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -2314,6 +2323,7 @@ dependencies = [
|
||||||
"clock",
|
"clock",
|
||||||
"collections",
|
"collections",
|
||||||
"context_menu",
|
"context_menu",
|
||||||
|
"convert_case",
|
||||||
"copilot",
|
"copilot",
|
||||||
"ctor",
|
"ctor",
|
||||||
"db",
|
"db",
|
||||||
|
|
|
@ -47,6 +47,7 @@ workspace = { path = "../workspace" }
|
||||||
|
|
||||||
aho-corasick = "0.7"
|
aho-corasick = "0.7"
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
convert_case = "0.6.0"
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
indoc = "1.0.4"
|
indoc = "1.0.4"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
|
@ -56,12 +57,12 @@ ordered-float.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
pulldown-cmark = { version = "0.9.2", default-features = false }
|
pulldown-cmark = { version = "0.9.2", default-features = false }
|
||||||
|
rand.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
rand.workspace = true
|
|
||||||
|
|
||||||
tree-sitter-rust = { workspace = true, optional = true }
|
tree-sitter-rust = { workspace = true, optional = true }
|
||||||
tree-sitter-html = { workspace = true, optional = true }
|
tree-sitter-html = { workspace = true, optional = true }
|
||||||
|
|
|
@ -28,6 +28,7 @@ use blink_manager::BlinkManager;
|
||||||
use client::{ClickhouseEvent, TelemetrySettings};
|
use client::{ClickhouseEvent, TelemetrySettings};
|
||||||
use clock::{Global, ReplicaId};
|
use clock::{Global, ReplicaId};
|
||||||
use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
|
use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
|
||||||
|
use convert_case::{Case, Casing};
|
||||||
use copilot::Copilot;
|
use copilot::Copilot;
|
||||||
pub use display_map::DisplayPoint;
|
pub use display_map::DisplayPoint;
|
||||||
use display_map::*;
|
use display_map::*;
|
||||||
|
@ -233,6 +234,11 @@ actions!(
|
||||||
ShuffleLines,
|
ShuffleLines,
|
||||||
ConvertToUpperCase,
|
ConvertToUpperCase,
|
||||||
ConvertToLowerCase,
|
ConvertToLowerCase,
|
||||||
|
ConvertToTitleCase,
|
||||||
|
ConvertToSnakeCase,
|
||||||
|
ConvertToKebabCase,
|
||||||
|
ConvertToUpperCamelCase,
|
||||||
|
ConvertToLowerCamelCase,
|
||||||
Transpose,
|
Transpose,
|
||||||
Cut,
|
Cut,
|
||||||
Copy,
|
Copy,
|
||||||
|
@ -357,6 +363,11 @@ pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(Editor::shuffle_lines);
|
cx.add_action(Editor::shuffle_lines);
|
||||||
cx.add_action(Editor::convert_to_upper_case);
|
cx.add_action(Editor::convert_to_upper_case);
|
||||||
cx.add_action(Editor::convert_to_lower_case);
|
cx.add_action(Editor::convert_to_lower_case);
|
||||||
|
cx.add_action(Editor::convert_to_title_case);
|
||||||
|
cx.add_action(Editor::convert_to_snake_case);
|
||||||
|
cx.add_action(Editor::convert_to_kebab_case);
|
||||||
|
cx.add_action(Editor::convert_to_upper_camel_case);
|
||||||
|
cx.add_action(Editor::convert_to_lower_camel_case);
|
||||||
cx.add_action(Editor::delete_to_previous_word_start);
|
cx.add_action(Editor::delete_to_previous_word_start);
|
||||||
cx.add_action(Editor::delete_to_previous_subword_start);
|
cx.add_action(Editor::delete_to_previous_subword_start);
|
||||||
cx.add_action(Editor::delete_to_next_word_end);
|
cx.add_action(Editor::delete_to_next_word_end);
|
||||||
|
@ -4318,6 +4329,34 @@ impl Editor {
|
||||||
self.manipulate_text(cx, |text| text.to_lowercase())
|
self.manipulate_text(cx, |text| text.to_lowercase())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn convert_to_title_case(&mut self, _: &ConvertToTitleCase, cx: &mut ViewContext<Self>) {
|
||||||
|
self.manipulate_text(cx, |text| text.to_case(Case::Title))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_to_snake_case(&mut self, _: &ConvertToSnakeCase, cx: &mut ViewContext<Self>) {
|
||||||
|
self.manipulate_text(cx, |text| text.to_case(Case::Snake))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_to_kebab_case(&mut self, _: &ConvertToKebabCase, cx: &mut ViewContext<Self>) {
|
||||||
|
self.manipulate_text(cx, |text| text.to_case(Case::Kebab))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_to_upper_camel_case(
|
||||||
|
&mut self,
|
||||||
|
_: &ConvertToUpperCamelCase,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
|
self.manipulate_text(cx, |text| text.to_case(Case::UpperCamel))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_to_lower_camel_case(
|
||||||
|
&mut self,
|
||||||
|
_: &ConvertToLowerCamelCase,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
|
self.manipulate_text(cx, |text| text.to_case(Case::Camel))
|
||||||
|
}
|
||||||
|
|
||||||
fn manipulate_text<Fn>(&mut self, cx: &mut ViewContext<Self>, mut callback: Fn)
|
fn manipulate_text<Fn>(&mut self, cx: &mut ViewContext<Self>, mut callback: Fn)
|
||||||
where
|
where
|
||||||
Fn: FnMut(&str) -> String,
|
Fn: FnMut(&str) -> String,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue