Checkpointing after some debugging

Mikayla Maki created

Change summary

crates/terminal/src/terminal.rs         |  1 
crates/terminal/src/terminal_element.rs | 29 +++++++++++++++++++++++---
2 files changed, 26 insertions(+), 4 deletions(-)

Detailed changes

crates/terminal/src/terminal.rs 🔗

@@ -484,6 +484,7 @@ mod tests {
                 let (chunks, _) = build_chunks(
                     term.lock().renderable_content().display_iter,
                     &Default::default(),
+                    0.,
                 );
                 let content = chunks.iter().map(|e| e.0.trim()).collect::<String>();
                 content.contains("7")

crates/terminal/src/terminal_element.rs 🔗

@@ -1,6 +1,6 @@
 use alacritty_terminal::{
     ansi::Color as AnsiColor,
-    grid::{GridIterator, Indexed},
+    grid::{Dimensions, GridIterator, Indexed},
     index::Point,
     term::{
         cell::{Cell, Flags},
@@ -121,8 +121,13 @@ impl Element for TerminalEl {
         let term = view_handle.read(cx).term.lock();
         let content = term.renderable_content();
 
+        //TODO: Remove
+        // dbg!("*******");
+        // dbg!(cur_size.columns());
+
         //And we're off! Begin layouting
-        let (chunks, line_count) = build_chunks(content.display_iter, &terminal_theme);
+        let (chunks, line_count) =
+            build_chunks(content.display_iter, &terminal_theme, cell_width.0);
 
         let shaped_lines = layout_highlighted_chunks(
             chunks
@@ -135,6 +140,11 @@ impl Element for TerminalEl {
             line_count,
         );
 
+        //TODO: Remove
+        // for shaped_line in &shaped_lines {
+        //     dbg!(shaped_line.width());
+        // }
+
         let backgrounds = chunks
             .iter()
             .filter(|(_, _, line_span)| line_span != &RectSpan::default())
@@ -290,6 +300,7 @@ impl Element for TerminalEl {
     }
 }
 
+///Configures a text style from the current settings.
 fn make_text_style(font_cache: &FontCache, settings: &Settings) -> TextStyle {
     TextStyle {
         color: settings.theme.editor.text_color,
@@ -304,6 +315,7 @@ fn make_text_style(font_cache: &FontCache, settings: &Settings) -> TextStyle {
     }
 }
 
+///Configures a size info object from the given information.
 fn make_new_size(
     constraint: SizeConstraint,
     cell_width: &CellWidth,
@@ -324,6 +336,7 @@ fn make_new_size(
 pub(crate) fn build_chunks(
     grid_iterator: GridIterator<Cell>,
     theme: &TerminalStyle,
+    em_width: f32,
 ) -> (Vec<(String, Option<HighlightStyle>, RectSpan)>, usize) {
     let mut line_count: usize = 0;
     //Every `group_by()` -> `into_iter()` pair needs to be seperated by a local variable so
@@ -356,8 +369,16 @@ pub(crate) fn build_chunks(
                 .chain(iter::once(("\n".to_string(), None, Default::default())))
                 .collect::<Vec<(String, Option<HighlightStyle>, RectSpan)>>()
         })
-        //We have a Vec<Vec<>> (Vec of lines of styled chunks), flatten to just Vec<> (the styled chunks)
+        //TODO: Remove
+        // .inspect(|line_chunks| {
+        //     let mut line_len = 0;
+        //     for chunk in line_chunks {
+        //         line_len += chunk.0.len();
+        //     }
+        //     dbg!((line_len, line_len as f32 * em_width));
+        // })
         .flatten()
+        //We have a Vec<Vec<>> (Vec of lines of styled chunks), flatten to just Vec<> (the styled chunks)
         .collect::<Vec<(String, Option<HighlightStyle>, RectSpan)>>();
     (result, line_count)
 }
@@ -398,7 +419,7 @@ fn get_cursor_position(
 ) -> Option<Vector2F> {
     let cursor_line = cursor_point.line.0 as usize + display_offset;
     shaped_lines.get(cursor_line).map(|layout_line| {
-        let cursor_x = layout_line.x_for_index(cursor_point.column.0);
+        let cursor_x = layout_line.x_for_index(cursor_point.column.0 + 3);
         vec2f(cursor_x, cursor_line as f32 * line_height.0)
     })
 }