diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 4ac88e6daa3d3623580e206c2759f27b218d1bac..79e092b709dd2778c89a79e1d6ce36802c853eb6 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -744,19 +744,14 @@ impl InlineAssistant { .update(cx, |editor, cx| { let scroll_top = editor.scroll_position(cx).y; let scroll_bottom = scroll_top + editor.visible_line_count().unwrap_or(0.); - let prompt_row = editor + editor_assists.scroll_lock = editor .row_for_block(decorations.prompt_block_id, cx) - .unwrap() - .0 as f32; - - if (scroll_top..scroll_bottom).contains(&prompt_row) { - editor_assists.scroll_lock = Some(InlineAssistScrollLock { + .map(|row| row.0 as f32) + .filter(|prompt_row| (scroll_top..scroll_bottom).contains(&prompt_row)) + .map(|prompt_row| InlineAssistScrollLock { assist_id, distance_from_top: prompt_row - scroll_top, }); - } else { - editor_assists.scroll_lock = None; - } }) .ok(); } @@ -917,14 +912,12 @@ impl InlineAssistant { editor.update(cx, |editor, cx| { let scroll_position = editor.scroll_position(cx); - let target_scroll_top = editor - .row_for_block(decorations.prompt_block_id, cx) - .unwrap() - .0 as f32 + let target_scroll_top = editor.row_for_block(decorations.prompt_block_id, cx)?.0 as f32 - scroll_lock.distance_from_top; if target_scroll_top != scroll_position.y { editor.set_scroll_position(point(scroll_position.x, target_scroll_top), window, cx); } + Some(()) }); } @@ -968,14 +961,14 @@ impl InlineAssistant { if let Some(decorations) = assist.decorations.as_ref() { let distance_from_top = editor.update(cx, |editor, cx| { let scroll_top = editor.scroll_position(cx).y; - let prompt_row = editor - .row_for_block(decorations.prompt_block_id, cx) - .unwrap() - .0 as f32; - prompt_row - scroll_top + let prompt_row = + editor.row_for_block(decorations.prompt_block_id, cx)?.0 as f32; + Some(prompt_row - scroll_top) }); - if distance_from_top != scroll_lock.distance_from_top { + if distance_from_top.is_none_or(|distance_from_top| { + distance_from_top != scroll_lock.distance_from_top + }) { editor_assists.scroll_lock = None; } } diff --git a/crates/gpui/src/platform/mac/metal_atlas.rs b/crates/gpui/src/platform/mac/metal_atlas.rs index 5d2d8e63e06a1ea6251c1fd2edf461eeeedec612..8282530c5efdc13ca95a1f04c0f6ef1a23c8366c 100644 --- a/crates/gpui/src/platform/mac/metal_atlas.rs +++ b/crates/gpui/src/platform/mac/metal_atlas.rs @@ -167,11 +167,14 @@ impl MetalAtlasState { if let Some(ix) = index { texture_list.textures[ix] = Some(atlas_texture); - texture_list.textures.get_mut(ix).unwrap().as_mut().unwrap() + texture_list.textures.get_mut(ix) } else { texture_list.textures.push(Some(atlas_texture)); - texture_list.textures.last_mut().unwrap().as_mut().unwrap() + texture_list.textures.last_mut() } + .unwrap() + .as_mut() + .unwrap() } fn texture(&self, id: AtlasTextureId) -> &MetalAtlasTexture {