MCPcopy Create free account
hub / github.com/GCWing/BitFun / cycle_block_tool_focus_prev

Method cycle_block_tool_focus_prev

src/apps/cli/src/ui/chat/tools.rs:46–72  ·  view source on GitHub ↗

Focus the previous block tool (Ctrl+U)

(&mut self, chat_state: &ChatState)

Source from the content-addressed store, hash-verified

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) {

Callers 1

handle_key_eventMethod · 0.80

Calls 6

iterMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected