| @@ -28,6 +28,7 @@ use blink_manager::BlinkManager; · 27 unmodified lines |
| 28 | use client::{ClickhouseEvent, TelemetrySettings}; | 28 | use client::{ClickhouseEvent, TelemetrySettings}; |
| 29 | use clock::{Global, ReplicaId}; | 29 | use clock::{Global, ReplicaId}; |
| 30 | use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque}; | 30 | use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque}; |
| | 31 | use convert_case::{Case, Casing}; |
| 31 | use copilot::Copilot; | 32 | use copilot::Copilot; |
| 32 | pub use display_map::DisplayPoint; | 33 | pub use display_map::DisplayPoint; |
| 33 | use display_map::*; | 34 | use display_map::*; |
| @@ -233,6 +234,11 @@ actions!( · 199 unmodified lines |
| 233 | ShuffleLines, | 234 | ShuffleLines, |
| 234 | ConvertToUpperCase, | 235 | ConvertToUpperCase, |
| 235 | ConvertToLowerCase, | 236 | ConvertToLowerCase, |
| | 237 | ConvertToTitleCase, |
| | 238 | ConvertToSnakeCase, |
| | 239 | ConvertToKebabCase, |
| | 240 | ConvertToUpperCamelCase, |
| | 241 | ConvertToLowerCamelCase, |
| 236 | Transpose, | 242 | Transpose, |
| 237 | Cut, | 243 | Cut, |
| 238 | Copy, | 244 | Copy, |
| @@ -357,6 +363,11 @@ pub fn init(cx: &mut AppContext) { · 118 unmodified lines |
| 357 | cx.add_action(Editor::shuffle_lines); | 363 | cx.add_action(Editor::shuffle_lines); |
| 358 | cx.add_action(Editor::convert_to_upper_case); | 364 | cx.add_action(Editor::convert_to_upper_case); |
| 359 | cx.add_action(Editor::convert_to_lower_case); | 365 | cx.add_action(Editor::convert_to_lower_case); |
| | 366 | cx.add_action(Editor::convert_to_title_case); |
| | 367 | cx.add_action(Editor::convert_to_snake_case); |
| | 368 | cx.add_action(Editor::convert_to_kebab_case); |
| | 369 | cx.add_action(Editor::convert_to_upper_camel_case); |
| | 370 | cx.add_action(Editor::convert_to_lower_camel_case); |
| 360 | cx.add_action(Editor::delete_to_previous_word_start); | 371 | cx.add_action(Editor::delete_to_previous_word_start); |
| 361 | cx.add_action(Editor::delete_to_previous_subword_start); | 372 | cx.add_action(Editor::delete_to_previous_subword_start); |
| 362 | cx.add_action(Editor::delete_to_next_word_end); | 373 | cx.add_action(Editor::delete_to_next_word_end); |
| @@ -4318,6 +4329,34 @@ impl Editor { · 3955 unmodified lines |
| 4318 | self.manipulate_text(cx, |text| text.to_lowercase()) | 4329 | self.manipulate_text(cx, |text| text.to_lowercase()) |
| 4319 | } | 4330 | } |
| 4320 | | 4331 | |
| | 4332 | pub fn convert_to_title_case(&mut self, _: &ConvertToTitleCase, cx: &mut ViewContext<Self>) { |
| | 4333 | self.manipulate_text(cx, |text| text.to_case(Case::Title)) |
| | 4334 | } |
| | 4335 | |
| | 4336 | pub fn convert_to_snake_case(&mut self, _: &ConvertToSnakeCase, cx: &mut ViewContext<Self>) { |
| | 4337 | self.manipulate_text(cx, |text| text.to_case(Case::Snake)) |
| | 4338 | } |
| | 4339 | |
| | 4340 | pub fn convert_to_kebab_case(&mut self, _: &ConvertToKebabCase, cx: &mut ViewContext<Self>) { |
| | 4341 | self.manipulate_text(cx, |text| text.to_case(Case::Kebab)) |
| | 4342 | } |
| | 4343 | |
| | 4344 | pub fn convert_to_upper_camel_case( |
| | 4345 | &mut self, |
| | 4346 | _: &ConvertToUpperCamelCase, |
| | 4347 | cx: &mut ViewContext<Self>, |
| | 4348 | ) { |
| | 4349 | self.manipulate_text(cx, |text| text.to_case(Case::UpperCamel)) |
| | 4350 | } |
| | 4351 | |
| | 4352 | pub fn convert_to_lower_camel_case( |
| | 4353 | &mut self, |
| | 4354 | _: &ConvertToLowerCamelCase, |
| | 4355 | cx: &mut ViewContext<Self>, |
| | 4356 | ) { |
| | 4357 | self.manipulate_text(cx, |text| text.to_case(Case::Camel)) |
| | 4358 | } |
| | 4359 | |
| 4321 | fn manipulate_text<Fn>(&mut self, cx: &mut ViewContext<Self>, mut callback: Fn) | 4360 | fn manipulate_text<Fn>(&mut self, cx: &mut ViewContext<Self>, mut callback: Fn) |
| 4322 | where | 4361 | where |
| 4323 | Fn: FnMut(&str) -> String, | 4362 | Fn: FnMut(&str) -> String, |