Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
perf(text_prompt): avoid unnecessary clones (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt authored May 11, 2024
1 parent 5a8e9b5 commit 366c7fb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ edition = "2021"
crossterm = "0.27.0"
itertools = "0.12.1"
ratatui = "0.26.2"
unicode-width = "0.1.12"

[dev-dependencies]
clap = { version = "4.5.4", features = ["derive"] }
Expand Down
3 changes: 1 addition & 2 deletions src/text_prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use ratatui::{
prelude::*,
widgets::{Block, Paragraph, StatefulWidget, Widget},
};
use unicode_width::UnicodeWidthStr;

// TODO style the widget
// TODO style each element of the widget.
Expand Down Expand Up @@ -101,7 +100,7 @@ impl<'a> StatefulWidget for TextPrompt<'a> {
" › ".cyan().dim(),
Span::raw(value),
]);
let prompt_length = line.to_string().width() - value_length;
let prompt_length = line.width() - value_length;
let lines = wrap(line, width).take(height).collect_vec();

// constrain the position to the area
Expand Down

0 comments on commit 366c7fb

Please sign in to comment.