Refactor: simplify word navigation logic, improve line wrapping, and enhance parameter initialization across core and TUI modules.
This commit is contained in:
@@ -52,23 +52,21 @@ pub fn build_cursor_map(text: &str, width: u16) -> Vec<ScreenPos> {
|
||||
word_start_col = col;
|
||||
word_start_idx = byte_offset + grapheme.len();
|
||||
}
|
||||
} else {
|
||||
if col + grapheme_width > width {
|
||||
if word_start_col > 0 && byte_offset == word_start_idx {
|
||||
// This is the first character of a new word that won't fit, wrap it
|
||||
row += 1;
|
||||
col = grapheme_width;
|
||||
} else if word_start_col == 0 {
|
||||
// No previous word boundary, hard break
|
||||
row += 1;
|
||||
col = grapheme_width;
|
||||
} else {
|
||||
// This is part of a word already on the line, let it extend beyond width
|
||||
col += grapheme_width;
|
||||
}
|
||||
} else if col + grapheme_width > width {
|
||||
if word_start_col > 0 && byte_offset == word_start_idx {
|
||||
// This is the first character of a new word that won't fit, wrap it
|
||||
row += 1;
|
||||
col = grapheme_width;
|
||||
} else if word_start_col == 0 {
|
||||
// No previous word boundary, hard break
|
||||
row += 1;
|
||||
col = grapheme_width;
|
||||
} else {
|
||||
// This is part of a word already on the line, let it extend beyond width
|
||||
col += grapheme_width;
|
||||
}
|
||||
} else {
|
||||
col += grapheme_width;
|
||||
}
|
||||
|
||||
// Set position for the end of this grapheme and any intermediate bytes
|
||||
|
||||
Reference in New Issue
Block a user