MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / current_token

Method current_token

crates/opencode-tui/src/components/prompt.rs:953–971  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

951 }
952
953 fn current_token(&self) -> Option<(usize, usize, String)> {
954 if self.input.is_empty() || self.cursor_position > self.input.len() {
955 return None;
956 }
957
958 let bytes = self.input.as_bytes();
959 let mut start = self.cursor_position;
960 while start > 0 && !bytes[start - 1].is_ascii_whitespace() {
961 start -= 1;
962 }
963
964 let mut end = self.cursor_position;
965 while end < bytes.len() && !bytes[end].is_ascii_whitespace() {
966 end += 1;
967 }
968
969 let token = self.input[start..self.cursor_position].to_string();
970 Some((start, end, token))
971 }
972
973 fn input_display_lines(&self, width: u16) -> u16 {
974 let reserved = 1u16

Callers 2

recompute_suggestionsMethod · 0.80

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected