From 89a6f2b62932f1125ba0eb8d67005eb2028999de Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 15 Aug 2021 16:32:27 -0400 Subject: [PATCH] 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. --- src/CLI2.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index bcfe1feb3..5d9ce3666 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -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().