From c00d9037e0ee9d3437b5f29f820a4010d440d205 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 6 Jun 2024 19:46:34 +0200 Subject: [PATCH 01/14] feat: Use System fonts --- crates/core/src/lib.rs | 2 ++ crates/core/src/style.rs | 12 ++++++++++++ crates/renderer/src/app.rs | 2 +- crates/renderer/src/config.rs | 9 ++++++--- crates/testing/src/launch.rs | 2 +- crates/testing/src/test_handler.rs | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 crates/core/src/style.rs diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 550f0b2ab..ba30ded9f 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -6,6 +6,7 @@ pub mod node; pub mod platform_state; pub mod plugins; pub mod render; +pub mod style; pub mod types; pub mod prelude { @@ -17,5 +18,6 @@ pub mod prelude { pub use crate::platform_state::*; pub use crate::plugins::*; pub use crate::render::*; + pub use crate::style::*; pub use crate::types::*; } diff --git a/crates/core/src/style.rs b/crates/core/src/style.rs new file mode 100644 index 000000000..33f0b843b --- /dev/null +++ b/crates/core/src/style.rs @@ -0,0 +1,12 @@ +pub fn default_fonts() -> Vec { + let mut fonts = vec!["Noto Sans".to_string(), "Arial".to_string()]; + if cfg!(target_os = "windows") { + fonts.insert(0, "Segoe UI".to_string()); + fonts.insert(1, "Segoe UI Emoji".to_string()); + } else if cfg!(target_os = "macos") { + fonts.insert(0, "San Francisco (SF)".to_string()); + } else if cfg!(target_os = "linux") { + fonts.insert(0, "Ubuntu".to_string()); + } + fonts +} diff --git a/crates/renderer/src/app.rs b/crates/renderer/src/app.rs index de028fbfa..c3acfbcf3 100644 --- a/crates/renderer/src/app.rs +++ b/crates/renderer/src/app.rs @@ -75,7 +75,7 @@ impl App { } let font_mgr: FontMgr = provider.into(); - font_collection.set_default_font_manager(def_mgr, "Fira Sans"); + font_collection.set_default_font_manager(def_mgr, None); font_collection.set_dynamic_font_manager(font_mgr.clone()); let (event_emitter, event_receiver) = mpsc::unbounded_channel(); diff --git a/crates/renderer/src/config.rs b/crates/renderer/src/config.rs index f603faee7..ecc7f0df9 100644 --- a/crates/renderer/src/config.rs +++ b/crates/renderer/src/config.rs @@ -1,6 +1,9 @@ use std::{io::Cursor, sync::Arc}; -use freya_core::plugins::{FreyaPlugin, PluginsManager}; +use freya_core::{ + plugins::{FreyaPlugin, PluginsManager}, + style::default_fonts, +}; use freya_engine::prelude::Color; use freya_node_state::Parse; use image::io::Reader; @@ -63,7 +66,7 @@ impl<'a, T: Clone> Default for LaunchConfig<'a, T> { window: Default::default(), embedded_fonts: Default::default(), plugins: Default::default(), - default_fonts: vec!["Fira Sans".to_string()], + default_fonts: default_fonts(), } } } @@ -133,7 +136,7 @@ impl Default for LaunchConfigBuilder<'_, T> { on_exit: None, plugins: PluginsManager::default(), window_builder_hook: None, - default_fonts: vec!["Fira Sans".to_string()], + default_fonts: default_fonts().to_vec(), } } } diff --git a/crates/testing/src/launch.rs b/crates/testing/src/launch.rs index 1adc04c45..bdef3f191 100644 --- a/crates/testing/src/launch.rs +++ b/crates/testing/src/launch.rs @@ -38,7 +38,7 @@ pub fn launch_test_with_config(root: AppComponent, config: TestingConfig) -> Tes let mut font_collection = FontCollection::new(); let font_mgr = FontMgr::default(); font_collection.set_dynamic_font_manager(font_mgr.clone()); - font_collection.set_default_font_manager(font_mgr, "Fira Sans"); + font_collection.set_default_font_manager(font_mgr, None); let mut handler = TestingHandler { vdom, diff --git a/crates/testing/src/test_handler.rs b/crates/testing/src/test_handler.rs index 2b5cbe943..8764f676e 100644 --- a/crates/testing/src/test_handler.rs +++ b/crates/testing/src/test_handler.rs @@ -184,7 +184,7 @@ impl TestingHandler { }, &mut self.font_collection, SCALE_FACTOR as f32, - &["Fira Sans".to_string()], + &default_fonts(), ); let dom = &self.utils.sdom().get_mut(); From 792de35608afdca5b77240af6760d4c7c02f7d0b Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 6 Jun 2024 22:09:15 +0200 Subject: [PATCH 02/14] simplify editing tests --- crates/hooks/tests/use_editable.rs | 41 +++--------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 751484984..d4e196077 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -386,18 +386,7 @@ pub async fn highlight_multiple_lines_single_editor() { utils.wait_for_update().await; let highlights = root.child(0).unwrap().state().cursor.highlights.clone(); - - #[cfg(not(target_os = "linux"))] - let start = 5; - #[cfg(not(target_os = "linux"))] - let end = 28; - - #[cfg(target_os = "linux")] - let start = 4; - #[cfg(target_os = "linux")] - let end = 27; - - assert_eq!(highlights, Some(vec![(start, end)])) + assert_eq!(highlights, Some(vec![(5, 28)])) } #[tokio::test] @@ -796,12 +785,8 @@ pub async fn backspace_remove() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(1).get(0); - #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:5")); - #[cfg(target_os = "linux")] - assert_eq!(cursor.text(), Some("0:4")); - // Insert text utils.push_event(PlatformEvent::Keyboard { name: EventName::KeyDown, @@ -1094,31 +1079,11 @@ pub async fn highlights_shift_click_single_line_mulitple_editors() { let highlights_1 = root.child(0).unwrap().state().cursor.highlights.clone(); - #[cfg(not(target_os = "linux"))] - let start = 5; - #[cfg(not(target_os = "linux"))] - let end = 17; - - #[cfg(target_os = "linux")] - let start = 4; - #[cfg(target_os = "linux")] - let end = 17; - - assert_eq!(highlights_1, Some(vec![(start, end)])); + assert_eq!(highlights_1, Some(vec![(5, 17)])); let highlights_2 = root.child(1).unwrap().state().cursor.highlights.clone(); - #[cfg(not(target_os = "linux"))] - let start = 0; - #[cfg(not(target_os = "linux"))] - let end = 11; - - #[cfg(target_os = "linux")] - let start = 0; - #[cfg(target_os = "linux")] - let end = 10; - - assert_eq!(highlights_2, Some(vec![(start, end)])); + assert_eq!(highlights_2, Some(vec![(0, 11)])); } #[tokio::test] From 65a976ae49934c6f9300ac86f3f26c59cc73d79f Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 6 Jun 2024 22:24:56 +0200 Subject: [PATCH 03/14] simplify more editing tests --- crates/hooks/tests/use_editable.rs | 116 ++++------------------------- 1 file changed, 13 insertions(+), 103 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index d4e196077..0fcb787f3 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -72,12 +72,8 @@ pub async fn multiple_lines_single_editor() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(1).get(0); - #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:5")); - #[cfg(target_os = "linux")] - assert_eq!(cursor.text(), Some("0:4")); - // Insert text utils.push_event(PlatformEvent::Keyboard { name: EventName::KeyDown, @@ -91,17 +87,8 @@ pub async fn multiple_lines_single_editor() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] - { - assert_eq!(content.text(), Some("Hello! Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:6")); - } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("Hell!o Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:5")); - } + assert_eq!(content.text(), Some("Hello! Rustaceans\nHello Rustaceans")); + assert_eq!(cursor.text(), Some("0:6")); // Move cursor to the begining utils.push_event(PlatformEvent::Mouse { @@ -270,12 +257,8 @@ pub async fn single_line_mulitple_editors() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(2).get(0); - #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:5")); - #[cfg(target_os = "linux")] - assert_eq!(cursor.text(), Some("0:4")); - // Insert text utils.push_event(PlatformEvent::Keyboard { name: EventName::KeyDown, @@ -290,17 +273,8 @@ pub async fn single_line_mulitple_editors() { let cursor = root.get(2).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] - { - assert_eq!(content.text(), Some("Hello! Rustaceans\n")); - assert_eq!(cursor.text(), Some("0:6")); - } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("Hell!o Rustaceans\n")); - assert_eq!(cursor.text(), Some("0:5")); - } + assert_eq!(content.text(), Some("Hello! Rustaceans\n")); + assert_eq!(cursor.text(), Some("0:6")); // Second line let content = root.get(1).get(0).get(0); @@ -494,32 +468,10 @@ pub async fn highlights_single_line_mulitple_editors() { utils.wait_for_update().await; let highlights_1 = root.child(0).unwrap().state().cursor.highlights.clone(); - - #[cfg(not(target_os = "linux"))] - let start = 5; - #[cfg(not(target_os = "linux"))] - let end = 17; - - #[cfg(target_os = "linux")] - let start = 4; - #[cfg(target_os = "linux")] - let end = 17; - - assert_eq!(highlights_1, Some(vec![(start, end)])); + assert_eq!(highlights_1, Some(vec![(5, 17)])); let highlights_2 = root.child(1).unwrap().state().cursor.highlights.clone(); - - #[cfg(not(target_os = "linux"))] - let start = 0; - #[cfg(not(target_os = "linux"))] - let end = 11; - - #[cfg(target_os = "linux")] - let start = 0; - #[cfg(target_os = "linux")] - let end = 10; - - assert_eq!(highlights_2, Some(vec![(start, end)])); + assert_eq!(highlights_2, Some(vec![(0, 11)])); } #[tokio::test] @@ -592,12 +544,8 @@ pub async fn special_text_editing() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(1).get(0); - #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:2")); - #[cfg(target_os = "linux")] - assert_eq!(cursor.text(), Some("0:4")); - // Insert text utils.push_event(PlatformEvent::Keyboard { name: EventName::KeyDown, @@ -611,17 +559,8 @@ pub async fn special_text_editing() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] - { - assert_eq!(content.text(), Some("你好🦀世界\n👋")); - assert_eq!(cursor.text(), Some("0:3")); - } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("你好世界🦀\n👋")); - assert_eq!(cursor.text(), Some("0:5")); - } + assert_eq!(content.text(), Some("你好🦀世界\n👋")); + assert_eq!(cursor.text(), Some("0:3")); // Move cursor to the begining utils.push_event(PlatformEvent::Mouse { @@ -801,17 +740,8 @@ pub async fn backspace_remove() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] - { - assert_eq!(content.text(), Some("Hello🦀 Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:6")); - } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("Hell🦀o Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:5")); - } + assert_eq!(content.text(), Some("Hello🦀 Rustaceans\nHello Rustaceans")); + assert_eq!(cursor.text(), Some("0:6")); // Remove text utils.push_event(PlatformEvent::Keyboard { @@ -827,17 +757,8 @@ pub async fn backspace_remove() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] - { - assert_eq!(content.text(), Some("Hello Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:5")); - } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("Hello Rustaceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:4")); - } + assert_eq!(content.text(), Some("Hello Rustaceans\nHello Rustaceans")); + assert_eq!(cursor.text(), Some("0:5")); } #[tokio::test] @@ -945,18 +866,7 @@ pub async fn highlight_shift_click_multiple_lines_single_editor() { utils.wait_for_update().await; let highlights = root.child(0).unwrap().state().cursor.highlights.clone(); - - #[cfg(not(target_os = "linux"))] - let start = 5; - #[cfg(not(target_os = "linux"))] - let end = 28; - - #[cfg(target_os = "linux")] - let start = 4; - #[cfg(target_os = "linux")] - let end = 27; - - assert_eq!(highlights, Some(vec![(start, end)])) + assert_eq!(highlights, Some(vec![(5, 28)])) } #[tokio::test] From 862636de48097e0dcb8cd3d50267441c24243ec9 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Fri, 7 Jun 2024 16:52:07 +0200 Subject: [PATCH 04/14] design improvements --- crates/components/src/button.rs | 1 + crates/elements/src/definitions.rs | 2 ++ crates/hooks/src/theming/light.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/components/src/button.rs b/crates/components/src/button.rs index 03dfadc98..6dfb4727b 100644 --- a/crates/components/src/button.rs +++ b/crates/components/src/button.rs @@ -181,6 +181,7 @@ pub fn Button( text_align: "center", main_align: "center", cross_align: "center", + line_height: "1", {&children} } ) diff --git a/crates/elements/src/definitions.rs b/crates/elements/src/definitions.rs index fbb45f8de..4d3d25322 100644 --- a/crates/elements/src/definitions.rs +++ b/crates/elements/src/definitions.rs @@ -229,6 +229,8 @@ builder_constructors! { opacity: String, #[doc = include_str!("_docs/attributes/content.md")] content: String, + #[doc = include_str!("_docs/attributes/line_height.md")] + line_height: String, name: String, focusable: String, diff --git a/crates/hooks/src/theming/light.rs b/crates/hooks/src/theming/light.rs index 99b8db6ef..b771453ae 100644 --- a/crates/hooks/src/theming/light.rs +++ b/crates/hooks/src/theming/light.rs @@ -23,7 +23,7 @@ pub const LIGHT_THEME: Theme = Theme { border_fill: cow_borrowed!("rgb(210, 210, 210)"), focus_border_fill: cow_borrowed!("rgb(180, 180, 180)"), shadow: cow_borrowed!("0 4 5 0 rgb(0, 0, 0, 0.1)"), - padding: cow_borrowed!("8 16"), + padding: cow_borrowed!("10 16"), margin: cow_borrowed!("4"), corner_radius: cow_borrowed!("8"), width: cow_borrowed!("auto"), From a406674728117e55a2d1328135ec21808ab7a77f Mon Sep 17 00:00:00 2001 From: marc2332 Date: Fri, 7 Jun 2024 16:53:06 +0200 Subject: [PATCH 05/14] update test --- crates/hooks/tests/use_editable.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 0fcb787f3..dcb49d898 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -544,8 +544,12 @@ pub async fn special_text_editing() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(1).get(0); + #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:2")); + #[cfg(target_os = "linux")] + assert_eq!(cursor.text(), Some("0:4")); + // Insert text utils.push_event(PlatformEvent::Keyboard { name: EventName::KeyDown, From 9b14d57f2293125f2c381a66be9b8ecfeea2794e Mon Sep 17 00:00:00 2001 From: marc2332 Date: Fri, 7 Jun 2024 17:02:37 +0200 Subject: [PATCH 06/14] update test --- crates/hooks/tests/use_editable.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index dcb49d898..9abc9eeb5 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -563,8 +563,17 @@ pub async fn special_text_editing() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - assert_eq!(content.text(), Some("你好🦀世界\n👋")); - assert_eq!(cursor.text(), Some("0:3")); + #[cfg(not(target_os = "linux"))] + { + assert_eq!(content.text(), Some("你好🦀世界\n👋")); + assert_eq!(cursor.text(), Some("0:3")); + } + + #[cfg(target_os = "linux")] + { + assert_eq!(content.text(), Some("你好世界🦀\n👋")); + assert_eq!(cursor.text(), Some("0:5")); + } // Move cursor to the begining utils.push_event(PlatformEvent::Mouse { From 6fca85f6683839bb13815ac2d0226d8aa4b49340 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 11 Jun 2024 15:05:17 +0200 Subject: [PATCH 07/14] fmt --- crates/renderer/src/config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/renderer/src/config.rs b/crates/renderer/src/config.rs index 6a09d358a..1c04c33e4 100644 --- a/crates/renderer/src/config.rs +++ b/crates/renderer/src/config.rs @@ -4,7 +4,10 @@ use std::{ }; use freya_core::{ - plugins::{FreyaPlugin, PluginsManager}, + plugins::{ + FreyaPlugin, + PluginsManager, + }, style::default_fonts, }; use freya_engine::prelude::Color; From 2536fa9cc81d13549e6b42ffd8b2c9be4a2a4a43 Mon Sep 17 00:00:00 2001 From: Marc Espin Date: Tue, 11 Jun 2024 18:40:40 +0200 Subject: [PATCH 08/14] Update crates/core/src/style.rs --- crates/core/src/style.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/core/src/style.rs b/crates/core/src/style.rs index 33f0b843b..63f8062a3 100644 --- a/crates/core/src/style.rs +++ b/crates/core/src/style.rs @@ -4,7 +4,7 @@ pub fn default_fonts() -> Vec { fonts.insert(0, "Segoe UI".to_string()); fonts.insert(1, "Segoe UI Emoji".to_string()); } else if cfg!(target_os = "macos") { - fonts.insert(0, "San Francisco (SF)".to_string()); + fonts.insert(0, ".AppleSystemUIFont".to_string()); } else if cfg!(target_os = "linux") { fonts.insert(0, "Ubuntu".to_string()); } From 9d6076a1f742ef6014428d8ac9d15b45576515aa Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 11 Jun 2024 18:45:28 +0200 Subject: [PATCH 09/14] fix tests for mac --- crates/hooks/tests/use_editable.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 554503c93..64684aaf6 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -365,7 +365,11 @@ pub async fn highlight_multiple_lines_single_editor() { utils.wait_for_update().await; let highlights = root.child(0).unwrap().state().cursor.highlights.clone(); - assert_eq!(highlights, Some(vec![(5, 28)])) + #[cfg(not(target_os = "macos"))] + assert_eq!(highlights, Some(vec![(5, 28)])); + + #[cfg(target_os = "macos")] + assert_eq!(highlights, Some(vec![(5, 27)])); } #[tokio::test] @@ -884,7 +888,11 @@ pub async fn highlight_shift_click_multiple_lines_single_editor() { utils.wait_for_update().await; let highlights = root.child(0).unwrap().state().cursor.highlights.clone(); - assert_eq!(highlights, Some(vec![(5, 28)])) + #[cfg(not(target_os = "macos"))] + assert_eq!(highlights, Some(vec![(5, 28)])); + + #[cfg(target_os = "macos")] + assert_eq!(highlights, Some(vec![(5, 27)])); } #[tokio::test] @@ -1011,7 +1019,11 @@ pub async fn highlights_shift_click_single_line_mulitple_editors() { let highlights_2 = root.child(1).unwrap().state().cursor.highlights.clone(); - assert_eq!(highlights_2, Some(vec![(0, 11)])); + #[cfg(not(target_os = "macos"))] + assert_eq!(highlights, Some(vec![(0, 11)])); + + #[cfg(target_os = "macos")] + assert_eq!(highlights, Some(vec![(0, 10)])); } #[tokio::test] From 38dc7055258f366e299ebea4f1ce5d80d11472fa Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 11 Jun 2024 18:48:52 +0200 Subject: [PATCH 10/14] fix test for mac --- crates/hooks/tests/use_editable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 64684aaf6..b0f279e55 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -1020,10 +1020,10 @@ pub async fn highlights_shift_click_single_line_mulitple_editors() { let highlights_2 = root.child(1).unwrap().state().cursor.highlights.clone(); #[cfg(not(target_os = "macos"))] - assert_eq!(highlights, Some(vec![(0, 11)])); + assert_eq!(highlights_2, Some(vec![(0, 11)])); #[cfg(target_os = "macos")] - assert_eq!(highlights, Some(vec![(0, 10)])); + assert_eq!(highlights_2, Some(vec![(0, 10)])); } #[tokio::test] From c2bcd660d622fc7785ea07866187e4858e77e403 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 11 Jun 2024 19:00:18 +0200 Subject: [PATCH 11/14] fix tests for mac --- crates/hooks/tests/use_editable.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index b0f279e55..6421aff66 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -480,7 +480,11 @@ pub async fn highlights_single_line_mulitple_editors() { assert_eq!(highlights_1, Some(vec![(5, 17)])); let highlights_2 = root.child(1).unwrap().state().cursor.highlights.clone(); + #[cfg(not(target_os = "macos"))] assert_eq!(highlights_2, Some(vec![(0, 11)])); + + #[cfg(target_os = "macos")] + assert_eq!(highlights_2, Some(vec![(0, 10)])); } #[tokio::test] @@ -1248,13 +1252,13 @@ pub async fn replace_text() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(not(target_os = "linux"))] + #[cfg(target_os = "windows")] { assert_eq!(content.text(), Some("Hello🦀ceans\nHello Rustaceans")); assert_eq!(cursor.text(), Some("0:6")); } - #[cfg(target_os = "linux")] + #[cfg(not(target_os = "windows"))] { assert_eq!(content.text(), Some("Hell🦀aceans\nHello Rustaceans")); assert_eq!(cursor.text(), Some("0:5")); From 2acdcd36e6bf61a366fd7169ac52d877337d50e1 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 11 Jun 2024 19:33:03 +0200 Subject: [PATCH 12/14] fix test for mac --- crates/hooks/tests/use_editable.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 6421aff66..37d2b0079 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -1258,7 +1258,13 @@ pub async fn replace_text() { assert_eq!(cursor.text(), Some("0:6")); } - #[cfg(not(target_os = "windows"))] + #[cfg(target_os = "macos")] + { + assert_eq!(content.text(), Some("Hello🦀aceans\nHello Rustaceans")); + assert_eq!(cursor.text(), Some("0:6")); + } + + #[cfg(target_os = "linux")] { assert_eq!(content.text(), Some("Hell🦀aceans\nHello Rustaceans")); assert_eq!(cursor.text(), Some("0:5")); From 95fc43364aac3b0bcdb64ba0f2f68fac5506e49d Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 16 Jun 2024 13:36:05 +0200 Subject: [PATCH 13/14] update test --- crates/hooks/tests/use_editable.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index f74d2f0fe..1f38091f1 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -1195,12 +1195,8 @@ pub async fn replace_text() { // Cursor has been moved let root = utils.root().get(0); let cursor = root.get(1).get(0); - #[cfg(not(target_os = "linux"))] assert_eq!(cursor.text(), Some("0:5")); - #[cfg(target_os = "linux")] - assert_eq!(cursor.text(), Some("0:4")); - // Click cursor utils.push_event(PlatformEvent::Mouse { name: EventName::MouseDown, From c9a795b953604bc8ff759737cd1ce859a4fbe8ff Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 16 Jun 2024 13:59:35 +0200 Subject: [PATCH 14/14] update test --- crates/hooks/tests/use_editable.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/hooks/tests/use_editable.rs b/crates/hooks/tests/use_editable.rs index 1f38091f1..cdb22df40 100644 --- a/crates/hooks/tests/use_editable.rs +++ b/crates/hooks/tests/use_editable.rs @@ -1248,7 +1248,7 @@ pub async fn replace_text() { // Text and cursor have changed let cursor = root.get(1).get(0); let content = root.get(0).get(0).get(0); - #[cfg(target_os = "windows")] + #[cfg(not(target_os = "macos"))] { assert_eq!(content.text(), Some("Hello🦀ceans\nHello Rustaceans")); assert_eq!(cursor.text(), Some("0:6")); @@ -1259,10 +1259,4 @@ pub async fn replace_text() { assert_eq!(content.text(), Some("Hello🦀aceans\nHello Rustaceans")); assert_eq!(cursor.text(), Some("0:6")); } - - #[cfg(target_os = "linux")] - { - assert_eq!(content.text(), Some("Hell🦀aceans\nHello Rustaceans")); - assert_eq!(cursor.text(), Some("0:5")); - } }