mirror of
https://github.com/wez/wezterm.git
synced 2024-09-11 14:25:57 +03:00
Reduce unicode_column_width call
This commit is contained in:
parent
1163d17496
commit
07ec769390
@ -90,7 +90,7 @@ impl crate::TermWindow {
|
|||||||
composing_text_width = unicode_column_width(text, None);
|
composing_text_width = unicode_column_width(text, None);
|
||||||
|
|
||||||
if let Some(attr) = attr {
|
if let Some(attr) = attr {
|
||||||
// convert text and attr to selections
|
// convert SELECTED attr to selections
|
||||||
let mut selection = 0usize..0;
|
let mut selection = 0usize..0;
|
||||||
// iterate over byte end of each character in text
|
// iterate over byte end of each character in text
|
||||||
for (i, end) in text
|
for (i, end) in text
|
||||||
@ -101,16 +101,23 @@ impl crate::TermWindow {
|
|||||||
.take(attr.len())
|
.take(attr.len())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
// update end to unicode width
|
// check last character/attr or SELECTED switch
|
||||||
let end = unicode_column_width(&text[..end], None);
|
let last = end == text.len() || i + 1 == attr.len();
|
||||||
if attr[i].contains(ComposingAttribute::SELECTED) {
|
if last || (attr[i] ^ attr[i + 1]).contains(ComposingAttribute::SELECTED) {
|
||||||
selection.end = end;
|
// update end to unicode width
|
||||||
}
|
let end = unicode_column_width(&text[..end], None);
|
||||||
// add non-empty selection and prepare next selection
|
// add selection to selections if attr[i] is end of SELECTED
|
||||||
if i + 1 == attr.len() || !attr[i].contains(ComposingAttribute::SELECTED) {
|
if attr[i].contains(ComposingAttribute::SELECTED) {
|
||||||
if !selection.is_empty() {
|
selection.end = end;
|
||||||
composing_selections.push(selection);
|
if !selection.is_empty() {
|
||||||
|
composing_selections.push(selection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// break if last character/attr is processed
|
||||||
|
if last {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// prepare selection for next SELECTED or start of SELECTED
|
||||||
selection = end..end;
|
selection = end..end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user