diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp index 6b02479a16..e4bc45fcf3 100644 --- a/Userland/Libraries/LibCpp/Lexer.cpp +++ b/Userland/Libraries/LibCpp/Lexer.cpp @@ -534,10 +534,13 @@ Vector Lexer::lex() if (directive == "#include") { commit_token(Token::Type::IncludeStatement); - begin_token(); - while (is_ascii_space(peek())) - consume(); - commit_token(Token::Type::Whitespace); + if (is_ascii_space(peek())) { + begin_token(); + do { + consume(); + } while (is_ascii_space(peek())); + commit_token(Token::Type::Whitespace); + } begin_token(); if (peek() == '<' || peek() == '"') {