TW-1652: task rm misparsed

- Thanks to Daniel Shahaf.
This commit is contained in:
Paul Beckingham 2015-08-07 19:33:27 -04:00
parent bbb0ac3d29
commit 38500fd90b
5 changed files with 34 additions and 15 deletions

View file

@ -118,6 +118,7 @@
- TW-1648 Typo in Documentation (thanks to Simon W. Jackson).
- TW-1651 Provide opt-out of filter parser's id treatment (thanks to Daniel
Shahaf).
- TW-1652 task rm misparsed (thanks to Daniel Shahaf).
- Prevent potential task duplication during import for non-pending tasks.
- Show the active context in "context list", if any is active.
- Fix "task edit" dropping annotation text after newlines.

1
NEWS
View file

@ -35,6 +35,7 @@ Removed features in 2.4.5
forms all contain sequences of digits that make the identification of
IDs, UUIDs, and various date/time formats problematic.
- Comma-separated UUID lists are no longer supported.
- DOM references may no longer be abbreviated.
Known Issues

View file

@ -854,11 +854,11 @@ void CLI2::aliasExpansion ()
}
else if (_aliases.find (raw) != _aliases.end ())
{
for (auto& l : Lexer::split (_aliases[raw]))
{
A2 a (l, Lexer::Type::word);
reconstructed.push_back (a);
}
std::string lexeme;
Lexer::Type type;
Lexer lex (_aliases[raw]);
while (lex.token (lexeme, type))
reconstructed.push_back (A2 (lexeme, type));
action = true;
changes = true;
@ -884,8 +884,11 @@ void CLI2::aliasExpansion ()
}
else if (_aliases.find (i) != _aliases.end ())
{
for (auto& l : Lexer::split (_aliases[i]))
reconstructedOriginals.push_back (l);
std::string lexeme;
Lexer::Type type;
Lexer lex (_aliases[i]);
while (lex.token (lexeme, type))
reconstructedOriginals.push_back (lexeme);
action = true;
changes = true;

View file

@ -1115,7 +1115,7 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
std::size_t checkpoint = _cursor;
// [prefix]tags.<word>
if (isLiteral ("tags", true, false) &&
if (isLiteral ("tags", false, false) &&
isLiteral (".", false, false) &&
isWord (partialToken, partialType))
{
@ -1127,7 +1127,7 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
_cursor = checkpoint;
// [prefix]attribute
if (isOneOf (attributes, true, true))
if (isOneOf (attributes, false, true))
{
token = _text.substr (marker, _cursor - marker);
type = Lexer::Type::dom;
@ -1135,7 +1135,7 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
}
// [prefix]attribute.
if (isOneOf (attributes, true, false))
if (isOneOf (attributes, false, false))
{
if (isLiteral (".", false, false))
{
@ -1146,7 +1146,7 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
isOneOf ({"year", "month", "day",
"week", "weekday",
"julian",
"hour", "minute", "second"}, true, true))
"hour", "minute", "second"}, false, true))
{
token = _text.substr (marker, _cursor - marker);
type = Lexer::Type::dom;
@ -1171,24 +1171,24 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
{
if (isLiteral (".", false, false))
{
if (isLiteral ("description", true, true))
if (isLiteral ("description", false, true))
{
token = _text.substr (marker, _cursor - marker);
type = Lexer::Type::dom;
return true;
}
else if (isLiteral ("entry", true, true))
else if (isLiteral ("entry", false, true))
{
token = _text.substr (marker, _cursor - marker);
type = Lexer::Type::dom;
return true;
}
else if (isLiteral ("entry", true, false) &&
else if (isLiteral ("entry", false, false) &&
isLiteral (".", false, false) &&
isOneOf ({"year", "month", "day",
"week", "weekday",
"julian",
"hour", "minute", "second"}, true, true))
"hour", "minute", "second"}, false, true))
{
token = _text.substr (marker, _cursor - marker);
type = Lexer::Type::dom;

View file

@ -142,6 +142,20 @@ class TestAliasesCommand(TestCase):
code, out, err = self.t("_aliases")
self.assertIn("foo", out)
class TestBug1652(TestCase):
def setUp(self):
"""Executed before each test in the class"""
self.t = Task()
self.t("add one")
def test_odd_alias(self):
"""Verify that 'delete' is not lexed further"""
self.t.config("alias.rm", "delete")
self.t.config("confirmation", "off")
code, out, err = self.t("1 rm")
self.assertIn("Deleted 1 task.", out)
self.assertNotIn("No matches.", out)
if __name__ == "__main__":
from simpletap import TAPTestRunner