Parcourir la source

check keyword existance on first token check

Llandy Riveron Del Risco il y a 3 ans
Parent
commit
2b077d6e12
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      parser/src/command/shortcut.rs

+ 3 - 3
parser/src/command/shortcut.rs

@@ -42,11 +42,11 @@ impl ShortcutCommand {
 
         let mut toks = input.clone();
         if let Some(Token::Word(word)) = toks.peek_token()? {
+            if !shortcuts.contains_key(word) {
+                return Ok(None);
+            }
             toks.next_token()?;
             if let Some(Token::Dot) | Some(Token::EndOfLine) = toks.peek_token()? {
-                if !shortcuts.contains_key(word) {
-                    return Ok(None);
-                }
                 toks.next_token()?;
                 *input = toks;
                 let command = shortcuts.get(word).unwrap();