Skip to content

Commit 706fb74

Browse files
committed
fix cursor misposition with unicode
1 parent c3c42ad commit 706fb74

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ discord-rich-presence = "1.0"
3939
futures = "0.3"
4040
itertools = "0.13"
4141
unicode-truncate = "2.0"
42+
unicode-width = "0.2"
4243
uuid = { version = "1", features = ["v4"] }
4344

4445
[dev-dependencies]

src/tui/ui.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ratatui::{
66
widgets::{Block, Borders, Gauge, List, ListItem, Paragraph},
77
};
88
use unicode_truncate::UnicodeTruncateStr;
9+
use unicode_width::UnicodeWidthStr;
910

1011
use crate::doctor::CheckStatus;
1112

@@ -413,7 +414,7 @@ fn draw_search(frame: &mut Frame, app: &App) {
413414
// Show cursor in search input
414415
if !app.is_searching {
415416
frame.set_cursor_position((
416-
chunks[1].x + app.search_input.len() as u16 + 1,
417+
chunks[1].x + app.search_input.width() as u16 + 1,
417418
chunks[1].y + 1,
418419
));
419420
}

0 commit comments

Comments
 (0)