Focus the previous block tool (Ctrl+U)
(&mut self, chat_state: &ChatState)
| 44 | |
| 45 | /// Focus the previous block tool (Ctrl+U) |
| 46 | pub fn cycle_block_tool_focus_prev(&mut self, chat_state: &ChatState) { |
| 47 | let block_tool_ids = self.collect_block_tool_ids(chat_state); |
| 48 | if block_tool_ids.is_empty() { |
| 49 | self.focused_block_tool = None; |
| 50 | self.invalidate_render_cache(); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | let current_idx = self |
| 55 | .focused_block_tool |
| 56 | .as_ref() |
| 57 | .and_then(|id| block_tool_ids.iter().position(|tid| tid == id)); |
| 58 | |
| 59 | let prev_idx = match current_idx { |
| 60 | Some(idx) => { |
| 61 | if idx == 0 { |
| 62 | block_tool_ids.len() - 1 |
| 63 | } else { |
| 64 | idx - 1 |
| 65 | } |
| 66 | } |
| 67 | None => block_tool_ids.len() - 1, // Start from the last one |
| 68 | }; |
| 69 | |
| 70 | self.focused_block_tool = Some(block_tool_ids[prev_idx].clone()); |
| 71 | self.invalidate_render_cache(); |
| 72 | } |
| 73 | |
| 74 | /// Focus the last block tool in the conversation |
| 75 | fn focus_last_block_tool(&mut self, chat_state: &ChatState) { |
no test coverage detected