From 2eea7805c6aee4e050efa09ce0b9597f50702b09 Mon Sep 17 00:00:00 2001 From: Wilhelm Schuermann Date: Thu, 2 Apr 2015 10:12:41 +0200 Subject: [PATCH] Lexer: Fix "task calc now+3days" error - Fix isDuration() consuming operators, leading to evaluation errors. Previously only "task calc now + 3days" worked, now the spaces are entirely optional. --- ChangeLog | 1 + src/Lexer.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e6124a46..11429de66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ amount of changes that is considered dangerous (thanks to Tomas Babej). - Disable hooks in bash completion script. Hooks were previously able to abort processing or output interfering data, breaking completion. +- Fix "task add due:tomorrow+3days" failing to work without spaces. ------ current release --------------------------- diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 29194c4dc..e11d20ac1 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -465,9 +465,18 @@ bool Lexer::isDate (std::string& token, Lexer::Type& type) // | bool Lexer::isDuration (std::string& token, Lexer::Type& type) { - std::size_t marker = 0; - + std::size_t marker = _cursor; ISO8601p iso; + + std::string extractedToken; + Lexer::Type extractedType; + if (isOperator(extractedToken, extractedType)) + { + _cursor = marker; + return false; + } + + marker = 0; if (iso.parse (_text.substr (_cursor), marker)) { type = Lexer::Type::duration;