mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(commands): make full string actually match the rest of the input again
This commit is contained in:
parent
413b8c1915
commit
b020e0a859
1 changed files with 19 additions and 7 deletions
|
|
@ -183,15 +183,27 @@ fn next_token(
|
|||
|
||||
// iterate over tokens and run try_match
|
||||
for token in possible_tokens {
|
||||
// for FullString just send the whole string
|
||||
let input_to_match = matched.as_ref().map(|v| v.value);
|
||||
// check if this is a token that matches the rest of the input
|
||||
let match_remaining = matches!(token, Token::FullString(_));
|
||||
// either use matched param or rest of the input if matching remaining
|
||||
let input_to_match = matched.as_ref().map(|v| {
|
||||
match_remaining
|
||||
.then_some(&input[current_pos..])
|
||||
.unwrap_or(v.value)
|
||||
});
|
||||
match token.try_match(input_to_match) {
|
||||
Some(Ok(value)) => {
|
||||
return Some(Ok((
|
||||
token,
|
||||
value,
|
||||
matched.map(|v| v.next_pos).unwrap_or(current_pos),
|
||||
)))
|
||||
// return last possible pos if we matched remaining,
|
||||
// otherwise use matched param next pos,
|
||||
// and if didnt match anything we stay where we are
|
||||
let next_pos = matched
|
||||
.map(|v| {
|
||||
match_remaining
|
||||
.then_some(input.len())
|
||||
.unwrap_or(v.next_pos)
|
||||
})
|
||||
.unwrap_or(current_pos);
|
||||
return Some(Ok((token, value, next_pos)));
|
||||
}
|
||||
Some(Err(err)) => {
|
||||
return Some(Err((token, err)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue