forked from 1b-agent/opencadstudio-upstream
Merge pull request #1340 from CiberNin/fix/editor-crashes
Fix editor crashes from typed input, text, and degenerate geometry
This commit is contained in:
commit
3c1ad62e9b
12 files changed
+391
-27
No files matched your search
@@ -798,9 +798,11 @@ pub fn reorder_line_atoms(atoms: Vec<LayoutAtom>, is_rtl: bool) -> Vec<LayoutAto
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let mut lvl = None;
|
||||
for i in r.clone() {
|
||||
// `bidi.levels` is indexed by byte, so walk characters rather than
|
||||
// bytes to avoid slicing inside a multi-byte character.
|
||||
for (offset, c) in line_text[r.clone()].char_indices() {
|
||||
let i = r.start + offset;
|
||||
if i < bidi.levels.len() {
|
||||
let c = line_text[i..].chars().next().unwrap_or(' ');
|
||||
match unicode_bidi::bidi_class(c) {
|
||||
unicode_bidi::BidiClass::L
|
||||
| unicode_bidi::BidiClass::R
|
||||
@@ -2966,6 +2968,12 @@ mod v_anchor_tests {
|
||||
reordered_b,
|
||||
vec!["2026 ", "is ", "here!", "שנה ", "שלום ", "مرحبا! ", "ہے۔ ", "اردو ", "یہ "]
|
||||
);
|
||||
|
||||
// Case 6: a word starting with multi-byte neutral punctuation must
|
||||
// not be sliced inside that character.
|
||||
let words6 = ["שלום", " ", "«x"];
|
||||
let reordered6 = reorder_atoms(&words6, false);
|
||||
assert_eq!(reordered6, vec!["שלום", " ", "«x"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user