fix(ui/explorer): tree search cursor not rendered

pull/9/head
wongjiahau 1 year ago
parent e5dfde2a9b
commit 1be2ac286b

@ -722,12 +722,17 @@ impl Component for Explorer {
}
fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
let prompt = match self.prompt.as_ref() {
Some((_, prompt)) => prompt,
None => return (None, CursorKind::Hidden),
};
let (x, y) = (area.x, area.y + area.height.saturating_sub(1));
prompt.cursor(Rect::new(x, y, area.width, 1), editor)
if let Some(prompt) = self
.prompt
.as_ref()
.map(|(_, prompt)| prompt)
.or_else(|| self.tree.prompt())
{
let (x, y) = (area.x, area.y + area.height.saturating_sub(1));
prompt.cursor(Rect::new(x, y, area.width, 1), editor)
} else {
(None, CursorKind::Hidden)
}
}
}

@ -477,6 +477,14 @@ impl<T: TreeViewItem> TreeView<T> {
Ok(())
}
}
pub fn prompt(&self) -> Option<&Prompt> {
if let Some((_, prompt)) = self.search_prompt.as_ref() {
Some(prompt)
} else {
None
}
}
}
pub fn tree_view_help() -> Vec<(&'static str, &'static str)> {

Loading…
Cancel
Save