Honor setting the selected range in addition to marking text
This commit is contained in:
parent
f712dec4c0
commit
eda60effed
3 changed files with 10 additions and 4 deletions
|
@ -5922,7 +5922,7 @@ impl View for Editor {
|
|||
&mut self,
|
||||
range: Option<Range<usize>>,
|
||||
text: &str,
|
||||
_new_selected_range: Option<Range<usize>>,
|
||||
new_selected_range: Option<Range<usize>>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue