fix(commands): don't use possible tokens, directly use branches.keys() since its ordered now

This commit is contained in:
dusk 2025-01-05 13:12:02 +09:00
parent eec9f64026
commit b477ade3fe
No known key found for this signature in database
2 changed files with 3 additions and 8 deletions

View file

@ -2,13 +2,10 @@ use ordermap::OrderMap;
use smol_str::SmolStr;
use crate::{commands::Command, Token};
use std::cmp::Ordering;
#[derive(Debug, Clone)]
pub struct TreeBranch {
pub current_command_key: Option<SmolStr>,
/// branches.keys(), but sorted by specificity
pub possible_tokens: Vec<Token>,
pub branches: OrderMap<Token, TreeBranch>,
}
@ -20,7 +17,6 @@ impl TreeBranch {
// recursively get or create a sub-branch for each token
current_branch = current_branch.branches.entry(token).or_insert(TreeBranch {
current_command_key: None,
possible_tokens: vec![],
branches: OrderMap::new(),
})
}
@ -29,7 +25,6 @@ impl TreeBranch {
Token::Empty,
TreeBranch {
current_command_key: Some(command.cb),
possible_tokens: vec![],
branches: OrderMap::new(),
},
);