bhcli

"Strange's fork of n0tr1v's bhcli (onion)"
git clone https://git.dasho.dev/Strange/bhcli.git
Log | Files | Refs | README

commit 1016e15d97f837d615d606946acae321dc2fbe9a
parent a2627b305593efd57fca81dd500b85168d174ee8
Author: Strange <StrangeGuy6228@protonmail.com>
Date:   Sat,  8 Mar 2025 23:49:38 +0530

Fixed the oiut char boundary bug

"byte index 1 is not a char boundary"
is finxed now :)

Diffstat:
Msrc/main.rs | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -2834,11 +2834,35 @@ fn gen_lines(msg_txt: &StyledText, w: usize, line_prefix: &str) -> Vec<Vec<(tuiC line.push((color, txt)); first_in_line = false; } else { - line.push((color, txt[0..remain].to_owned())); + //line.push((color, txt[0..remain].to_owned())); + if let Some(valid_slice) = txt.get(0..remain) { + line.push((color, valid_slice.to_owned())); + } else { + let valid_remain = txt.char_indices() + .take_while(|&(i, _)| i < remain) + .last() + .map(|(i, _)| i) + .unwrap_or(txt.len()); + + line.push((color, txt[..valid_remain].to_owned())); + } + new_lines.push(line.clone()); line.clear(); line.push((tuiColor::White, line_prefix.to_owned())); - ctxt.push((color, txt[(remain)..].to_owned())); + //ctxt.push((color, txt[(remain)..].to_owned())); + if let Some(valid_slice) = txt.get(remain..) { + ctxt.push((color, valid_slice.to_owned())); + } else { + let valid_remain = txt.char_indices() + .skip_while(|&(i, _)| i < remain) // Find first valid boundary after remain + .map(|(i, _)| i) + .next() + .unwrap_or(txt.len()); + + ctxt.push((color, txt[valid_remain..].to_owned())); + } + ptr = 0; split_idx += 1; first_in_line = true;