mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
CLI2: Prevent loops
- Context was sometimes causing looping: ::analyze -> ::addContexFilter -> ::addFilter -> ::analyze This is prevented by a simple latch.
This commit is contained in:
parent
7da3f3b2ba
commit
3897c23c8d
2 changed files with 8 additions and 0 deletions
|
@ -328,6 +328,7 @@ void CLI2::applyOverrides (int argc, const char** argv)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CLI2::CLI2 ()
|
||||
: _context_filter_added (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -579,6 +580,10 @@ void CLI2::addFilter (const std::string& arg)
|
|||
// - filter contains ID or UUID
|
||||
void CLI2::addContextFilter ()
|
||||
{
|
||||
// Recursion block.
|
||||
if (_context_filter_added)
|
||||
return;
|
||||
|
||||
// Detect if any context is set, and bail out if not
|
||||
std::string contextName = context.config.get ("context");
|
||||
if (contextName == "")
|
||||
|
@ -607,6 +612,7 @@ void CLI2::addContextFilter ()
|
|||
context.debug ("Context '" + contextName + "' not defined.");
|
||||
else
|
||||
{
|
||||
_context_filter_added = true;
|
||||
addFilter (contextFilter);
|
||||
if (context.verbose ("context"))
|
||||
context.footnote (format ("Context '{1}' set. Use 'task context none' to remove.", contextName));
|
||||
|
@ -621,6 +627,7 @@ void CLI2::prepareFilter ()
|
|||
// Clear and re-populate.
|
||||
_id_ranges.clear ();
|
||||
_uuid_list.clear ();
|
||||
_context_filter_added = false;
|
||||
|
||||
// Remove all the syntactic sugar for FILTERs.
|
||||
lexFilterArgs ();
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
|
||||
std::vector <std::pair <std::string, std::string>> _id_ranges;
|
||||
std::vector <std::string> _uuid_list;
|
||||
bool _context_filter_added;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue