CLI2: Apply UUID/ID context break only for readable context

The purpose of this break is to not apply the context on commands like

    task 4 info

so that we can still refer to tasks directly (using their ID/UUID
references) even if they fall outside of the currectly active context.

However, this break should not be applied for writeable context. This is
because the lexer can (a bit misleadingly) label parts of the desription
of the new task as number/identifier tokens

   task add Replace 3 parts of the puzzle abc123
                    ^                     ^
                    type::number          type:uuid

which would trigger the break unnecessarily.

Closes #2550.
This commit is contained in:
Tomas Babej 2021-08-15 16:32:27 -04:00
parent 5a86a40220
commit 89a6f2b629

View file

@ -607,17 +607,18 @@ void CLI2::addContext (bool readable, bool writeable)
if (contextString.empty ())
return;
// Detect if UUID or ID is set, and bail out
for (auto& a : _args)
{
if (a._lextype == Lexer::Type::uuid ||
a._lextype == Lexer::Type::number ||
a._lextype == Lexer::Type::set)
// For readable contexts: Detect if UUID or ID is set, and bail out
if (readable)
for (auto& a : _args)
{
Context::getContext ().debug (format ("UUID/ID argument found '{1}', not applying context.", a.attribute ("raw")));
return;
if (a._lextype == Lexer::Type::uuid ||
a._lextype == Lexer::Type::number ||
a._lextype == Lexer::Type::set)
{
Context::getContext ().debug (format ("UUID/ID argument found '{1}', not applying context.", a.attribute ("raw")));
return;
}
}
}
// Apply the context. Readable (filtering) takes precedence. Also set the
// block now, since addFilter calls analyze(), which calls addContext().