mirror of
https://github.com/gitui-org/gitui
synced 2026-05-22 16:38:28 +00:00
branchlist was ignoring unicode boundaries on truncating strings (#603)
* branchlist was ignoring unicode boundaries on truncating strings (fixes #602)
This commit is contained in:
parent
0a3c3c85a8
commit
2e5b344c04
3 changed files with 13 additions and 2 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
|
@ -366,6 +366,7 @@ dependencies = [
|
|||
"simplelog",
|
||||
"textwrap 0.13.4",
|
||||
"tui",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
"which",
|
||||
]
|
||||
|
|
@ -1173,6 +1174,14 @@ version = "1.7.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-truncate"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/Aetf/unicode-truncate.git#b1821b0af6801b81e1f1f900526748754f8cd44f"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ serde = "1.0"
|
|||
anyhow = "1.0"
|
||||
unicode-width = "0.1"
|
||||
textwrap = "0.13"
|
||||
unicode-truncate = {version="0.2", git="https://github.com/Aetf/unicode-truncate.git"}
|
||||
|
||||
[target.'cfg(all(target_family="unix",not(target_os="macos")))'.dependencies]
|
||||
which = "4.0"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use tui::{
|
|||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use unicode_truncate::UnicodeTruncateStr;
|
||||
|
||||
use crate::ui::Size;
|
||||
use anyhow::Result;
|
||||
|
|
@ -334,7 +335,7 @@ impl BranchListComponent {
|
|||
let mut commit_message =
|
||||
displaybranch.top_commit_message.clone();
|
||||
if commit_message.len() > commit_message_length {
|
||||
commit_message.truncate(
|
||||
commit_message.unicode_truncate(
|
||||
commit_message_length
|
||||
.saturating_sub(THREE_DOTS_LENGTH),
|
||||
);
|
||||
|
|
@ -343,7 +344,7 @@ impl BranchListComponent {
|
|||
|
||||
let mut branch_name = displaybranch.name.clone();
|
||||
if branch_name.len() > branch_name_length {
|
||||
branch_name.truncate(
|
||||
branch_name.unicode_truncate(
|
||||
branch_name_length
|
||||
.saturating_sub(THREE_DOTS_LENGTH),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue