diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b3698b6ad9..ba5ae4eefe 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5922,7 +5922,7 @@ impl View for Editor { &mut self, range: Option>, text: &str, - _new_selected_range: Option>, + new_selected_range: Option>, cx: &mut ViewContext, ) { self.transact(cx, |this, cx| { @@ -5948,6 +5948,10 @@ impl View for Editor { ); this.handle_input(text, cx); + + if let Some(new_selected_range) = new_selected_range { + this.set_selected_text_range(new_selected_range, cx); + } }); } } diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 3bd4bd28a0..a049f5753f 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -449,10 +449,12 @@ impl InputHandler for WindowInputHandler { // TODO - do these need to be handled separately? fn cancel_composition(&mut self) { + println!("cancel_composition()"); self.unmark_text(); } fn finish_composition(&mut self) { + println!("finish_composition()"); self.unmark_text(); } } diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index e7bffa6ecd..097a53b260 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -775,7 +775,7 @@ extern "C" fn handle_key_equivalent(this: &Object, _: Sel, native_event: id) -> &text, new_selected_range, ) - } else if had_marked_text && !inserted_text { + } else if had_marked_text && !has_marked_text && !inserted_text { if pending_event.unmark_text { input_handler.finish_composition(); } else { @@ -1194,9 +1194,9 @@ extern "C" fn attributed_substring_for_proposed_range( } unsafe { - let selected_text = ns_string(&input_handler.text_for_range(intersection)?); + let selected_text = input_handler.text_for_range(intersection)?; let string: id = msg_send![class!(NSAttributedString), alloc]; - let string: id = msg_send![string, initWithString: selected_text]; + let string: id = msg_send![string, initWithString: ns_string(&selected_text)]; Some(string) } })