diff --git a/Cargo.lock b/Cargo.lock index 5ad33587..426127e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2833,6 +2833,7 @@ dependencies = [ "aho-corasick", "anyhow", "chrono", + "core-text", "enum-iterator", "gpui", "gpui-component-macros", diff --git a/README.md b/README.md index 433c2973..37a5194f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Here is the first application: [Longbridge Pro](https://longbridge.com/desktop), ```toml gpui = "0.2.2" -gpui-component = "0.4.0" +gpui-component = "0.5.1" ``` ### Basic Example diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 90d12cd1..e075682f 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -18,4 +18,4 @@ quote = "1.0" syn = "2.0" [package.metadata.cargo-machete] -ignored = ["proc-macro2"] +ignored = ["proc-macro2", "core-text"] diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index dc14dfc6..d24e4fcf 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -127,6 +127,9 @@ tree-sitter-typescript = { version = "0.23.2", optional = true } tree-sitter-yaml = { version = "0.7.1", optional = true } tree-sitter-zig = { version = "1.1.2", optional = true } +[target.'cfg(target_os = "macos")'.dependencies] +core-text = "=21.0.0" + [dev-dependencies] gpui = { workspace = true, features = ["test-support"] } indoc = "2" diff --git a/crates/ui/src/input/state.rs b/crates/ui/src/input/state.rs index 51b6642e..89b3ffa9 100644 --- a/crates/ui/src/input/state.rs +++ b/crates/ui/src/input/state.rs @@ -925,8 +925,7 @@ impl InputState { let left_part = self.text.slice(0..offset).to_string(); UnicodeSegmentation::split_word_bound_indices(left_part.as_str()) - .filter(|(_, s)| !s.trim_start().is_empty()) - .next_back() + .rfind(|(_, s)| !s.trim_start().is_empty()) .map(|(i, _)| i) .unwrap_or(0) } diff --git a/crates/ui/src/menu/popup_menu.rs b/crates/ui/src/menu/popup_menu.rs index e7703977..03bba86b 100644 --- a/crates/ui/src/menu/popup_menu.rs +++ b/crates/ui/src/menu/popup_menu.rs @@ -1232,13 +1232,10 @@ impl Render for PopupMenu { let view = cx.entity().clone(); let items_count = self.menu_items.len(); - let max_height = self.max_height.map_or_else( - || { - let window_half_height = window.window_bounds().get_bounds().size.height * 0.5; - window_half_height.min(px(450.)) - }, - |height| height, - ); + let max_height = self.max_height.unwrap_or_else(|| { + let window_half_height = window.window_bounds().get_bounds().size.height * 0.5; + window_half_height.min(px(450.)) + }); let has_left_icon = self .menu_items diff --git a/crates/ui/src/text/text_view.rs b/crates/ui/src/text/text_view.rs index 0e0b9ec4..1906a6ac 100644 --- a/crates/ui/src/text/text_view.rs +++ b/crates/ui/src/text/text_view.rs @@ -484,7 +484,7 @@ impl TextView { pub fn style(mut self, style: TextViewStyle) -> Self { if let Some(init_state) = &mut self.init_state { match init_state { - InitState::Initializing { style: s, .. } => *s = Box::new(style), + InitState::Initializing { style: s, .. } => **s = style, InitState::Initialized { tx } => { let _ = tx.try_send(Update::Style(Box::new(style))); }