|
|
|
@ -323,14 +323,14 @@ impl DatabaseTree {
|
|
|
|
|
if item.kind().is_database() {
|
|
|
|
|
if item.kind().is_database_collapsed() {
|
|
|
|
|
self.items.expand(current_selection, false);
|
|
|
|
|
return None;
|
|
|
|
|
return Some(current_selection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if item.kind().is_schema() {
|
|
|
|
|
if item.kind().is_schema_collapsed() {
|
|
|
|
|
self.items.expand(current_selection, false);
|
|
|
|
|
return None;
|
|
|
|
|
return Some(current_selection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -437,6 +437,62 @@ mod test {
|
|
|
|
|
assert_eq!(tree.selection, Some(2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_expand() {
|
|
|
|
|
let items = vec![Database::new(
|
|
|
|
|
"a".to_string(),
|
|
|
|
|
vec![Table::new("b".to_string()).into()],
|
|
|
|
|
)];
|
|
|
|
|
|
|
|
|
|
// a
|
|
|
|
|
// b
|
|
|
|
|
|
|
|
|
|
let mut tree = DatabaseTree::new(&items, &BTreeSet::new()).unwrap();
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Enter));
|
|
|
|
|
assert!(!tree.items.tree_items[0].kind().is_database_collapsed());
|
|
|
|
|
assert_eq!(tree.selection, Some(0));
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Down));
|
|
|
|
|
assert_eq!(tree.selection, Some(1));
|
|
|
|
|
|
|
|
|
|
assert!(!tree.move_selection(MoveSelection::Enter));
|
|
|
|
|
assert_eq!(tree.selection, Some(1));
|
|
|
|
|
|
|
|
|
|
let items = vec![Database::new(
|
|
|
|
|
"a".to_string(),
|
|
|
|
|
vec![Schema {
|
|
|
|
|
name: "b".to_string(),
|
|
|
|
|
tables: vec![Table::new("c".to_string()).into()],
|
|
|
|
|
}
|
|
|
|
|
.into()],
|
|
|
|
|
)];
|
|
|
|
|
|
|
|
|
|
// a
|
|
|
|
|
// b
|
|
|
|
|
// c
|
|
|
|
|
|
|
|
|
|
let mut tree = DatabaseTree::new(&items, &BTreeSet::new()).unwrap();
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Enter));
|
|
|
|
|
assert!(!tree.items.tree_items[0].kind().is_database_collapsed());
|
|
|
|
|
assert!(tree.items.tree_items[1].kind().is_schema_collapsed());
|
|
|
|
|
assert_eq!(tree.selection, Some(0));
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Down));
|
|
|
|
|
assert_eq!(tree.selection, Some(1));
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Enter));
|
|
|
|
|
assert!(!tree.items.tree_items[1].kind().is_database_collapsed());
|
|
|
|
|
assert_eq!(tree.selection, Some(1));
|
|
|
|
|
|
|
|
|
|
assert!(tree.move_selection(MoveSelection::Down));
|
|
|
|
|
assert_eq!(tree.selection, Some(2));
|
|
|
|
|
|
|
|
|
|
assert!(!tree.move_selection(MoveSelection::Enter));
|
|
|
|
|
assert_eq!(tree.selection, Some(2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_selection_multiple_up_down() {
|
|
|
|
|
let items = vec![Database::new(
|
|
|
|
|