From cd643884518ee0d5274fc8bfba16865492478b56 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Thu, 1 Dec 2022 17:59:03 -0700 Subject: [PATCH] Added BiDi example to demonstrate reordering works and disabled `wrap simple` since it's not working properly. --- sample/farsi.txt | 3 ++- src/edit/syntect.rs | 4 ++-- src/shape.rs | 8 ++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sample/farsi.txt b/sample/farsi.txt index 5f3baf4..c19432f 100644 --- a/sample/farsi.txt +++ b/sample/farsi.txt @@ -7,4 +7,5 @@ ویرگول (؛). تای تأنیث یا ه دو نقطه (ة). علامت تشدید (ــّـ). - +Testing LEFT‑TO‑RIGHT ISOLATE (U+2066) and POP DIRECTIONAL ISOLATE (U+2069): +He said: "بهتره از ⁦Rust⁩ استفاده کنی". diff --git a/src/edit/syntect.rs b/src/edit/syntect.rs index 88c4280..32cdcb3 100644 --- a/src/edit/syntect.rs +++ b/src/edit/syntect.rs @@ -225,7 +225,7 @@ impl<'a> Edit<'a> for SyntaxEditor<'a> { // Update line attributes. This operation only resets if the line changes line.set_attrs_list(attrs_list); - line.set_wrap_simple(true); + line.set_wrap_simple(false); //TODO: efficiently do syntax highlighting without having to shape whole buffer buffer.line_shape(line_i); @@ -246,7 +246,7 @@ impl<'a> Edit<'a> for SyntaxEditor<'a> { if highlighted > 0 { buffer.set_redraw(true); #[cfg(feature = "std")] - log::debug!("Syntax highlighted {} lines in {:?}", highlighted, now.elapsed()); + log::debug!("Syntax highlighted {} lines in {:?}", highlighted, now.elapsed()); } self.editor.shape_as_needed(); diff --git a/src/shape.rs b/src/shape.rs index e546438..1855a93 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -420,8 +420,6 @@ impl ShapeSpan { pub struct ShapeLine { pub rtl: bool, pub spans: Vec, - pub levels: Vec, - pub runs: Vec>, } impl ShapeLine { @@ -431,8 +429,6 @@ impl ShapeLine { attrs_list: &AttrsList ) -> Self { let mut spans = Vec::new(); - let levels = Vec::new(); - let runs = Vec::new(); let bidi = unicode_bidi::BidiInfo::new(line, None); let rtl = if bidi.paragraphs.is_empty() { @@ -449,7 +445,7 @@ impl ShapeLine { if line_rtl { for range in runs.into_iter().rev() { - let span_rtl = levels[range.start].is_rtl(); //paragraph.info.levels[i].is_rtl(); + let span_rtl = levels[range.start].is_rtl(); spans.push(ShapeSpan::new( font_system, line, @@ -480,7 +476,7 @@ impl ShapeLine { line_rtl }; - Self { rtl, spans, levels, runs } + Self { rtl, spans} } pub fn layout(