diff --git a/src/renderer/cursor_renderer.rs b/src/renderer/cursor_renderer.rs index fb10497..0b3095d 100644 --- a/src/renderer/cursor_renderer.rs +++ b/src/renderer/cursor_renderer.rs @@ -201,12 +201,17 @@ impl CursorRenderer { let (character, font_dimensions): (String, Point) = { let editor = EDITOR.lock().unwrap(); - let character = editor.grid[grid_y as usize][grid_x as usize].clone() + let character = editor.grid + .get(grid_y as usize) + .and_then(|row| row.get(grid_x as usize).cloned()) + .flatten() .map(|(character, _)| character) .unwrap_or(' '.to_string()); - let is_double = editor.grid[grid_y as usize] - .get(grid_x as usize + 1) - .map(|cell| cell.as_ref().map(|(character, _)| character.is_empty()).unwrap_or(false)) + let is_double = editor.grid + .get(grid_y as usize) + .and_then(|row| row.get(grid_x as usize + 1).cloned()) + .flatten() + .map(|(character, _)| character.is_empty()) .unwrap_or(false); let font_width = match (is_double, &cursor.shape) { diff --git a/src/window.rs b/src/window.rs index 53f5b58..e02d08a 100644 --- a/src/window.rs +++ b/src/window.rs @@ -167,18 +167,15 @@ pub fn ui_loop() { } } - Event::RedrawRequested { .. } => { + Event::RedrawRequested { .. } => { let frame_start = Instant::now(); if REDRAW_SCHEDULER.should_draw() { - if let Err(e) = skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| { + skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| { if renderer.draw(canvas, coordinate_system_helper) { handle_new_grid_size(window.inner_size(), &renderer) } - - }) { - println!("Error during draw: {:?}", e); - } + }).ok(); } *control_flow = ControlFlow::WaitUntil(frame_start + Duration::from_secs_f32(1.0 / 60.0));