Skip to content

Commit

Permalink
Don't handle text input when IME is being composed
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Jan 27, 2022
1 parent bd77486 commit 1ccdf9e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion alacritty/src/display/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a> RenderableContent<'a> {
// Find terminal cursor shape.
let cursor_shape = if terminal_content.cursor.shape == CursorShape::Hidden
|| display.cursor_hidden
|| display.ime_input.is_some()
|| display.has_ime_input()
|| search_state.regex().is_some()
{
CursorShape::Hidden
Expand Down
13 changes: 10 additions & 3 deletions alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ impl Display {
})
}

pub fn has_ime_input(&self) -> bool {
match self.ime_input.as_ref() {
Some(ime_input) if !ime_input.preedit.is_empty() => true,
_ => false,
}
}

fn new_glyph_cache(
dpr: f64,
renderer: &mut QuadRenderer,
Expand Down Expand Up @@ -497,8 +504,8 @@ impl Display {
) {
let size_info = &self.size_info;
let ime_input = match self.ime_input.as_ref() {
Some(ime_input) => ime_input,
None => {
Some(ime_input) if !ime_input.preedit.is_empty() => ime_input,
_ => {
let ime_popup_point = Point::new(Line(point.line as i32), point.column);
self.window.update_ime_position(ime_popup_point, size_info);
return;
Expand Down Expand Up @@ -691,7 +698,7 @@ impl Display {
self.draw_inline_preedit(ime_point, fg, bg, &mut rects, &metrics, config);

// Push search bar cursor if there's no IME.
if self.ime_input.is_none() {
if !self.has_ime_input() {
let shape = CursorShape::Underline;
let cursor = RenderableCursor::new(Point::new(line, column), shape, fg, false);
rects.extend(
Expand Down
6 changes: 6 additions & 0 deletions alacritty/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {

/// Process key input.
pub fn key_input(&mut self, input: KeyboardInput) {
// Don't process anything if we have IME input.
if self.ctx.display().has_ime_input() {
*self.ctx.suppress_chars() = true;
return;
}

// All key bindings are disabled while a hint is being selected.
if self.ctx.display().hint_state.active() {
*self.ctx.suppress_chars() = false;
Expand Down

0 comments on commit 1ccdf9e

Please sign in to comment.