diff --git a/frontends/rioterm/src/renderer/mod.rs b/frontends/rioterm/src/renderer/mod.rs index 9f2f36d2..7f4dd587 100644 --- a/frontends/rioterm/src/renderer/mod.rs +++ b/frontends/rioterm/src/renderer/mod.rs @@ -665,9 +665,27 @@ impl Renderer { last_style = style; content.push(' '); // Ignore font shaping + } else if is_blank { + // Accumulate into pending blank run + if !content.is_empty() { + if let Some(line) = line_opt { + builder.add_span_on_line(line, &content, last_style); + } else { + builder.add_span(&content, last_style); + } + content.clear(); + } + if pending_blank_width == 0.0 { + pending_blank_style = style; + } + pending_blank_width += 1.0; + last_style = style; } else { - if is_blank { - // Accumulate into pending blank run + // Break runs when styles differ in ways that affect shaping + // or when background color changes (for search highlights, etc.) + if !styles_are_compatible_for_shaping(&last_style, &style) + || last_style.background_color != style.background_color + { if !content.is_empty() { if let Some(line) = line_opt { builder.add_span_on_line(line, &content, last_style); @@ -676,31 +694,11 @@ impl Renderer { } content.clear(); } - if pending_blank_width == 0.0 { - pending_blank_style = style; - } - pending_blank_width += 1.0; - last_style = style; - } else { - // Break runs when styles differ in ways that affect shaping - // or when background color changes (for search highlights, etc.) - if !styles_are_compatible_for_shaping(&last_style, &style) - || last_style.background_color != style.background_color - { - if !content.is_empty() { - if let Some(line) = line_opt { - builder.add_span_on_line(line, &content, last_style); - } else { - builder.add_span(&content, last_style); - } - content.clear(); - } - - last_style = style; - } - content.push(square_content); + last_style = style; } + + content.push(square_content); } // Render last column and break row diff --git a/frontends/rioterm/src/screen/mod.rs b/frontends/rioterm/src/screen/mod.rs index 74cd9f27..f1ec0d05 100644 --- a/frontends/rioterm/src/screen/mod.rs +++ b/frontends/rioterm/src/screen/mod.rs @@ -3346,7 +3346,10 @@ impl Screen<'_> { self.sugarloaf.render(); let sugarloaf_duration = sugarloaf_start.elapsed(); let total_duration = screen_render_start.elapsed(); - println!("[screen] sugarloaf.render: {:?} | total: {:?}", sugarloaf_duration, total_duration); + println!( + "[screen] sugarloaf.render: {:?} | total: {:?}", + sugarloaf_duration, total_duration + ); // Mark as dirty if we need continuous rendering (e.g., indeterminate progress bar) if self.renderer.needs_redraw() { diff --git a/sugarloaf/src/font/text_run_cache.rs b/sugarloaf/src/font/text_run_cache.rs index 0b2274ca..94f8c4b8 100644 --- a/sugarloaf/src/font/text_run_cache.rs +++ b/sugarloaf/src/font/text_run_cache.rs @@ -96,11 +96,6 @@ impl TextRunCache { } } - #[inline] - fn bucket_ptr(&self, idx: usize) -> *const Entry { - self.buckets[idx].as_ptr() as *const Entry - } - #[inline] fn bucket_ptr_mut(&mut self, idx: usize) -> *mut Entry { self.buckets[idx].as_mut_ptr() as *mut Entry diff --git a/sugarloaf/src/layout/content.rs b/sugarloaf/src/layout/content.rs index 92f332a7..444523fe 100644 --- a/sugarloaf/src/layout/content.rs +++ b/sugarloaf/src/layout/content.rs @@ -1015,8 +1015,7 @@ impl Content { // Process the font data directly without cloning FontRef let font_library = &fonts.inner.read(); - if let Some((shared_data, offset, key)) = font_library.get_data(&font_id) - { + if let Some((shared_data, offset, key)) = font_library.get_data(&font_id) { let font_ref = FontRef { data: shared_data.as_ref(), offset, diff --git a/sugarloaf/src/renderer/mod.rs b/sugarloaf/src/renderer/mod.rs index 3bd7885d..cd77a29a 100644 --- a/sugarloaf/src/renderer/mod.rs +++ b/sugarloaf/src/renderer/mod.rs @@ -1145,8 +1145,7 @@ impl Renderer { // Use pre-computed cache key — no String allocation needed let t1 = std::time::Instant::now(); let cached_result = if run.cache_key != 0 { - self.text_run_manager - .get_cached_data_by_key(run.cache_key) + self.text_run_manager.get_cached_data_by_key(run.cache_key) } else { CacheResult::Miss }; @@ -1390,7 +1389,7 @@ impl Renderer { } let t_lines_total = t_lines_start.elapsed(); - let t_graphics = t_after_graphics.elapsed() - t_lines_total; + let _t_graphics = t_after_graphics.elapsed() - t_lines_total; println!( "[draw_layout] lines: {:?} | empty: {} text: {} | cache: {}µs glyphs: {}µs draw_run: {}µs", t_lines_total, diff --git a/sugarloaf/src/renderer/text_run_manager.rs b/sugarloaf/src/renderer/text_run_manager.rs index 12a448fb..3d8a0a2b 100644 --- a/sugarloaf/src/renderer/text_run_manager.rs +++ b/sugarloaf/src/renderer/text_run_manager.rs @@ -6,7 +6,7 @@ // Unified text run manager - replaces separate line cache and shaping cache use crate::font::text_run_cache::{ - create_cached_text_run, create_text_run_key, ShapedGlyph, TextRunCache, + create_cached_text_run, ShapedGlyph, TextRunCache, }; use std::sync::Arc; use tracing::debug; @@ -50,30 +50,6 @@ impl TextRunManager { self.unified_cache.insert(key, cached_run); } - /// Get cached shaping data for a text run (legacy string-based API) - pub fn get_cached_data( - &mut self, - text: &str, - font_id: usize, - font_size: f32, - ) -> CacheResult { - let key = create_text_run_key(text, font_id, font_size); - self.get_cached_data_by_key(key) - } - - /// Cache shaping data for a text run (legacy string-based API) - pub fn cache_shaping_data( - &mut self, - text: &str, - font_id: usize, - font_size: f32, - glyphs: Vec, - has_emoji: bool, - ) { - let key = create_text_run_key(text, font_id, font_size); - self.cache_shaping_data_by_key(key, font_id, font_size, glyphs, has_emoji); - } - /// Apply cached vertices to output, adjusting for new position #[cfg(test)] pub fn apply_cached_vertices(