From 48407080905a0487f3de36a710cb3541b1f47764 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 22 Dec 2010 09:31:00 -0500 Subject: [PATCH] Bug #579 - Fixed bug #579, which displayed incorrect counts when using the 'limit:N' filter (thanks to Thomas Sattler). - Changed wording from 'lines' to 'tasks', because the former was inaccurate. - Adjusted limit.t tests accordingly. --- AUTHORS | 1 + ChangeLog | 2 ++ NEWS | 1 + src/custom.cpp | 14 +++++++++++--- src/tests/limit.t | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0ffc3b01f..cfb6b1795 100644 --- a/AUTHORS +++ b/AUTHORS @@ -68,4 +68,5 @@ suggestions: Itay Perl Max Muller Sander Marechal + Thomas Sattler diff --git a/ChangeLog b/ChangeLog index fedd0a346..4f3728955 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,8 @@ Michelle Crane). + Fixed bug #555, which caused a segfault when logging a task with a project (thanks to Itay Perl). + + Fixed bug #579, which displayed incorrect counts when using the 'limit:N' + filter (thanks to Thomas Sattler). ------ old releases ------------------------------ diff --git a/NEWS b/NEWS index 2e86b6b39..74936375e 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ New Features in taskwarrior 1.9.4 - The first month in the calendar report can now be changed with an offset value. - No more dependency on ncurses. + - Assorted bug fixes. Please refer to the ChangeLog file for full details. There are too many to list here. diff --git a/src/custom.cpp b/src/custom.cpp index ff6e93d1f..3028c9f05 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -635,6 +635,14 @@ int handleCustomReport (const std::string& report, std::string& outs) table.setTableAlternateColor (alternate); } + // How many lines taken up by table header? + int table_header; + if ((context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) && + context.config.getBoolean ("fontunderline")) + table_header = 1; // Underlining doesn't use extra line. + else + table_header = 2; // Dashes use an extra line. + // Report output can be limited by rows or lines. int maxrows = 0; int maxlines = 0; @@ -643,7 +651,7 @@ int handleCustomReport (const std::string& report, std::string& outs) // Adjust for fluff in the output. if (maxlines) maxlines -= (context.config.getBoolean ("blanklines") ? 2 : 0) - + 1 + + table_header + context.headers.size () + context.footnotes.size (); @@ -656,11 +664,11 @@ int handleCustomReport (const std::string& report, std::string& outs) << table.rowCount () << (table.rowCount () == 1 ? " task" : " tasks"); - if (maxrows) + if (maxrows && maxrows < table.rowCount ()) out << ", " << maxrows << " shown"; if (maxlines && maxlines < table.rowCount ()) - out << ", truncated to " << maxlines - 1 << " lines"; + out << ", truncated to " << maxlines - table_header << " tasks"; out << std::endl; } diff --git a/src/tests/limit.t b/src/tests/limit.t index 1419d1e27..f43a89939 100755 --- a/src/tests/limit.t +++ b/src/tests/limit.t @@ -80,7 +80,7 @@ $output = qx{../task rc:limit.rc ls limit:3}; like ($output, qr/^30 tasks, 3 shown$/ms, 'limited to 3'); $output = qx{../task rc:limit.rc ls limit:page}; -like ($output, qr/^30 tasks, truncated to 20 lines$/ms, 'limited to page'); +like ($output, qr/^30 tasks, truncated to 17 tasks$/ms, 'limited to page'); # Cleanup. unlink 'pending.data';