From 76f5fb937c4ed2516041728f0d4b7bb541a3d5fd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 19 Feb 2018 08:29:04 +1100 Subject: [PATCH] Fix bug in command parsing post refactoring Fixes #1857 --- src/command_manager.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 899203b2..ed489183 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -297,7 +297,8 @@ Optional CommandParser::read_token(bool throw_on_unterminated) String token = get_until_delimiter(m_reader, c); if (throw_on_unterminated and not m_reader) throw parse_error{format("unterminated string {0}...{0}", c)}; - ++m_reader; + if (m_reader) + ++m_reader; return Token{c == '"' ? Token::Type::RawEval : Token::Type::RawQuoted, start - line.begin(), coord, std::move(token)}; @@ -305,7 +306,8 @@ Optional CommandParser::read_token(bool throw_on_unterminated) else if (c == '%') { auto token = parse_percent_token(m_reader, throw_on_unterminated); - ++m_reader; + if (m_reader) + ++m_reader; return token; } else if (is_command_separator(*m_reader)) @@ -604,7 +606,7 @@ Completions CommandManager::complete(const Context& context, case Token::Type::RawQuoted: case Token::Type::RawEval: { - if (token.type != Token::Type::Raw) + if (token.type != Token::Type::Raw and token.type != Token::Type::RawQuoted) return Completions{}; StringView command_name = tokens.front().content;