mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-31 19:05:00 +07:00
terminal: Fix last character of IME marked text not being deleted (#46224)
This commit is contained in:
parent
22415e5f49
commit
a1263830bb
2 changed files with 8 additions and 14 deletions
|
|
@ -1488,12 +1488,12 @@ impl InputHandler for TerminalInputHandler {
|
|||
&mut self,
|
||||
_range_utf16: Option<std::ops::Range<usize>>,
|
||||
new_text: &str,
|
||||
new_marked_range: Option<std::ops::Range<usize>>,
|
||||
_new_marked_range: Option<std::ops::Range<usize>>,
|
||||
_window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
self.terminal_view.update(cx, |view, view_cx| {
|
||||
view.set_marked_text(new_text.to_string(), new_marked_range, view_cx);
|
||||
view.set_marked_text(new_text.to_string(), view_cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ use std::{
|
|||
|
||||
struct ImeState {
|
||||
marked_text: String,
|
||||
marked_range_utf16: Option<Range<usize>>,
|
||||
}
|
||||
|
||||
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
|
||||
|
|
@ -327,16 +326,11 @@ impl TerminalView {
|
|||
}
|
||||
|
||||
/// Sets the marked (pre-edit) text from the IME.
|
||||
pub(crate) fn set_marked_text(
|
||||
&mut self,
|
||||
text: String,
|
||||
range: Option<Range<usize>>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.ime_state = Some(ImeState {
|
||||
marked_text: text,
|
||||
marked_range_utf16: range,
|
||||
});
|
||||
pub(crate) fn set_marked_text(&mut self, text: String, cx: &mut Context<Self>) {
|
||||
if text.is_empty() {
|
||||
return self.clear_marked_text(cx);
|
||||
}
|
||||
self.ime_state = Some(ImeState { marked_text: text });
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +338,7 @@ impl TerminalView {
|
|||
pub(crate) fn marked_text_range(&self) -> Option<Range<usize>> {
|
||||
self.ime_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.marked_range_utf16.clone())
|
||||
.map(|state| 0..state.marked_text.encode_utf16().count())
|
||||
}
|
||||
|
||||
/// Clears the marked (pre-edit) text state.
|
||||
|
|
|
|||
Loading…
Reference in a new issue