Merge remote-tracking branch 'origin/main' into window-handles
This commit is contained in:
@@ -2698,6 +2698,84 @@ async fn test_manipulate_lines_with_multi_selection(cx: &mut TestAppContext) {
|
||||
"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_manipulate_text(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
|
||||
// Test convert_to_upper_case()
|
||||
cx.set_state(indoc! {"
|
||||
«hello worldˇ»
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_upper_case(&ConvertToUpperCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«HELLO WORLDˇ»
|
||||
"});
|
||||
|
||||
// Test convert_to_lower_case()
|
||||
cx.set_state(indoc! {"
|
||||
«HELLO WORLDˇ»
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_lower_case(&ConvertToLowerCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«hello worldˇ»
|
||||
"});
|
||||
|
||||
// From here on out, test more complex cases of manipulate_text()
|
||||
|
||||
// Test no selection case - should affect words cursors are in
|
||||
// Cursor at beginning, middle, and end of word
|
||||
cx.set_state(indoc! {"
|
||||
ˇhello big beauˇtiful worldˇ
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_upper_case(&ConvertToUpperCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«HELLOˇ» big «BEAUTIFULˇ» «WORLDˇ»
|
||||
"});
|
||||
|
||||
// Test multiple selections on a single line and across multiple lines
|
||||
cx.set_state(indoc! {"
|
||||
«Theˇ» quick «brown
|
||||
foxˇ» jumps «overˇ»
|
||||
the «lazyˇ» dog
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_upper_case(&ConvertToUpperCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«THEˇ» quick «BROWN
|
||||
FOXˇ» jumps «OVERˇ»
|
||||
the «LAZYˇ» dog
|
||||
"});
|
||||
|
||||
// Test case where text length grows
|
||||
cx.set_state(indoc! {"
|
||||
«tschüߡ»
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_upper_case(&ConvertToUpperCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«TSCHÜSSˇ»
|
||||
"});
|
||||
|
||||
// Test to make sure we don't crash when text shrinks
|
||||
cx.set_state(indoc! {"
|
||||
aaa_bbbˇ
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_lower_camel_case(&ConvertToLowerCamelCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«aaaBbbˇ»
|
||||
"});
|
||||
|
||||
// Test to make sure we all aware of the fact that each word can grow and shrink
|
||||
// Final selections should be aware of this fact
|
||||
cx.set_state(indoc! {"
|
||||
aaa_bˇbb bbˇb_ccc ˇccc_ddd
|
||||
"});
|
||||
cx.update_editor(|e, cx| e.convert_to_lower_camel_case(&ConvertToLowerCamelCase, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«aaaBbbˇ» «bbbCccˇ» «cccDddˇ»
|
||||
"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_duplicate_line(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
Reference in New Issue
Block a user