diff --git a/ChangeLog b/ChangeLog index 64e9c2632..cafbc41e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,8 @@ Babej). - Show the active context in "context list", if any is active. - Fix "task edit" dropping annotation text after newlines. - Removed obsolete script 'context'. +- Fix "project" verbosity info not showing without "footnote" being manually +enabled. ------ current release --------------------------- diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index f712dd3e0..35fe0d126 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -275,6 +275,8 @@ control specific occasions when output is generated. This list may contain: sync Feedback about sync filter Shows the filter used in the command +"affected", "new-id", "new-uuid" and "project" imply "footnote". + Note that the "on" setting is equivalent to all the tokens being specified, and the "nothing" setting is equivalent to none of the tokens being specified. diff --git a/src/Context.cpp b/src/Context.cpp index 8bd251f92..12ff6718c 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -508,7 +508,7 @@ bool Context::color () // take the place of '0'. bool Context::verbose (const std::string& token) { - if (! verbosity.size ()) + if (verbosity.empty ()) { verbosity_legacy = config.getBoolean ("verbose"); split (verbosity, config.get ("verbose"), ','); @@ -517,24 +517,40 @@ bool Context::verbose (const std::string& token) // This odd test is to see if a Boolean-false value is a real one, which // means it is not 1/true/T/yes/on, but also should not be one of the // valid tokens either. - if (!verbosity_legacy && - verbosity.size () && - verbosity[0] != "nothing" && - verbosity[0] != "blank" && // This list must be complete. - verbosity[0] != "header" && // - verbosity[0] != "footnote" && // - verbosity[0] != "label" && // - verbosity[0] != "new-id" && // - verbosity[0] != "new-uuid" && // - verbosity[0] != "affected" && // - verbosity[0] != "edit" && // - verbosity[0] != "special" && // - verbosity[0] != "project" && // - verbosity[0] != "sync" && // - verbosity[0] != "filter") // + if (!verbosity_legacy && ! verbosity.empty ()) { - // This list emulates rc.verbose=off in version 1.9.4. - verbosity = {"blank", "label", "new-id", "edit"}; + std::string v = *(verbosity.begin ()); + if (v != "nothing" && + v != "blank" && // This list must be complete. + v != "header" && // + v != "footnote" && // + v != "label" && // + v != "new-id" && // + v != "new-uuid" && // + v != "affected" && // + v != "edit" && // + v != "special" && // + v != "project" && // + v != "sync" && // + v != "filter") // + { + // This list emulates rc.verbose=off in version 1.9.4. + verbosity = {"blank", "label", "new-id", "edit"}; + } + } + + // Some flags imply "footnote" verbosity being active. Make it so. + if (! verbosity.count ("footnote")) + { + // TODO: Some of these may not use footnotes yet. They should. + for (auto flag : {"affected", "new-id", "new-uuid", "project"}) + { + if (verbosity.count (flag)) + { + verbosity.insert ("footnote"); + break; + } + } } } @@ -544,11 +560,11 @@ bool Context::verbose (const std::string& token) // rc.verbose=nothing overrides all. if (verbosity.size () == 1 && - verbosity[0] == "nothing") + *(verbosity.begin ()) == "nothing") return false; // Specific token match. - if (std::find (verbosity.begin (), verbosity.end (), token) != verbosity.end ()) + if (verbosity.count (token)) return true; return false; diff --git a/src/Context.h b/src/Context.h index 64ea6f044..63bf5e853 100644 --- a/src/Context.h +++ b/src/Context.h @@ -37,6 +37,7 @@ #include #include #include +#include class Context { @@ -95,7 +96,7 @@ public: bool run_gc; bool verbosity_legacy; - std::vector verbosity; + std::set verbosity; std::vector headers; std::vector footnotes; std::vector errors; diff --git a/src/text.cpp b/src/text.cpp index 80aec833e..0ed87a1c4 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -60,6 +60,25 @@ void wrapText ( lines.push_back (line); } +//////////////////////////////////////////////////////////////////////////////// +void split ( + std::set& results, + const std::string& input, + const char delimiter) +{ + results.clear (); + std::string::size_type start = 0; + std::string::size_type i; + while ((i = input.find (delimiter, start)) != std::string::npos) + { + results.insert (input.substr (start, i - start)); + start = i + 1; + } + + if (input.length ()) + results.insert (input.substr (start)); +} + //////////////////////////////////////////////////////////////////////////////// void split ( std::vector& results, diff --git a/src/text.h b/src/text.h index 7f412e1f1..b0f79f780 100644 --- a/src/text.h +++ b/src/text.h @@ -27,6 +27,7 @@ #ifndef INCLUDED_TEXT #define INCLUDED_TEXT +#include #include #include @@ -39,6 +40,7 @@ std::string unquoteText (const std::string&); int longestWord (const std::string&); int longestLine (const std::string&); bool extractLine (std::string&, const std::string&, int, bool, unsigned int&); +void split (std::set&, const std::string&, const char); void split (std::vector&, const std::string&, const char); void split (std::vector&, const std::string&, const std::string&); void join (std::string&, const std::string&, const std::vector&);