use super::AppModel;
use crate::keymap::InspectorTab;
use crate::search::{Address, Found};
impl AppModel {
pub fn search(&self, text: &str) {
self.search.ask(text);
}
pub fn found(&self) -> Found {
self.search.found()
}
pub fn searching(&self) -> bool {
self.search.searching()
}
pub(crate) fn search_cell(&self) -> crate::state::SearchCell {
self.search.clone()
}
pub fn open(&mut self, at: &Address) {
match at {
Address::Ball { project, id } => {
if let Some(ws) = self.ball_workspace(project, id) {
self.focus_workspace(&crate::naming::leaf(&ws));
}
}
Address::Workspace { path } => self.focus_workspace(&crate::naming::leaf(path)),
Address::Conversation { workspace, agent } => {
self.focus_agent(workspace, agent);
self.select_tab(InspectorTab::Transcript);
}
}
}
fn ball_workspace(&self, project: &std::path::Path, id: &str) -> Option<std::path::PathBuf> {
let project = self.snap.project_name(project);
self.snap
.join_rows
.iter()
.find(|r| r.project == project && r.ball_id == id)
.and_then(|r| self.snap.ws_path(r.workspace.as_deref()?).ok())
}
}