mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 10:10:12 +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
|
// iterate over tokens and run try_match
|
||||||
for token in possible_tokens {
|
for token in possible_tokens {
|
||||||
// for FullString just send the whole string
|
// check if this is a token that matches the rest of the input
|
||||||
let input_to_match = matched.as_ref().map(|v| v.value);
|
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) {
|
match token.try_match(input_to_match) {
|
||||||
Some(Ok(value)) => {
|
Some(Ok(value)) => {
|
||||||
return Some(Ok((
|
// return last possible pos if we matched remaining,
|
||||||
token,
|
// otherwise use matched param next pos,
|
||||||
value,
|
// and if didnt match anything we stay where we are
|
||||||
matched.map(|v| v.next_pos).unwrap_or(current_pos),
|
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)) => {
|
Some(Err(err)) => {
|
||||||
return Some(Err((token, err)));
|
return Some(Err((token, err)));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue