diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd8f69b..d7c7603e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Pasting into clients only supporting `UTF8_STRING` mime type on Wayland - Crash when copying/pasting with neither pointer nor keyboard focus on Wayland - Crash due to fd leak on Wayland +- IME window position with fullwidth characters in the search bar ## 0.5.0 diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs index 00bfd83a..ca5bfe34 100644 --- a/alacritty/src/display.rs +++ b/alacritty/src/display.rs @@ -598,7 +598,7 @@ impl Display { self.draw_search(config, &size_info, message_bar_lines, &search_text); // Compute IME position. - Point::new(size_info.lines() - 1, Column(search_text.len() - 1)) + Point::new(size_info.lines() - 1, Column(search_text.chars().count() - 1)) }, None => cursor_point, }; @@ -640,10 +640,11 @@ impl Display { // Truncate beginning of the search regex if it exceeds the viewport width. let num_cols = size_info.cols().0; - let label_len = search_label.len(); - let regex_len = formatted_regex.len(); + let label_len = search_label.chars().count(); + let regex_len = formatted_regex.chars().count(); let truncate_len = min((regex_len + label_len).saturating_sub(num_cols), regex_len); - let truncated_regex = &formatted_regex[truncate_len..]; + let index = formatted_regex.char_indices().nth(truncate_len).map(|(i, _c)| i).unwrap_or(0); + let truncated_regex = &formatted_regex[index..]; // Add search label to the beginning of the search regex. let mut bar_text = format!("{}{}", search_label, truncated_regex);