diff --git a/ChangeLog b/ChangeLog index 6000fdb23..7967411c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -47,6 +47,7 @@ Harlan). - TW-255 'Mask' instead of 'iMask' shown in info report (thanks to Benjamin Weber) +- TW-257 limit: not working properly (thanks to Aikido Guy). - TW-259 Hyphenated words are split when added (thanks to Ben Boeckel). - TW-261 Easy to create "not deletable" task (thanks to Jan Kunder). - TW-266 Allow project auto-completion to search completed tasks (thanks to diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index 73d18826b..06f0b6709 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -53,8 +53,11 @@ int CmdExport::execute (std::string& output) std::vector filtered; filter.subset (filtered); - // Note: "limit:" feature not supported. - // TODO Why not? + // Obey 'limit:N'. + int rows = 0; + int lines = 0; + context.getLimits (rows, lines); + int limit = (rows > lines ? rows : lines); // Is output contained within a JSON array? bool json_array = context.config.getBoolean ("json.array"); @@ -63,6 +66,7 @@ int CmdExport::execute (std::string& output) if (json_array) output += "[\n"; + int counter = 0; std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) { @@ -70,6 +74,9 @@ int CmdExport::execute (std::string& output) output += ",\n"; output += task->composeJSON (true); + + if (limit && ++counter >= limit) + break; } if (filtered.size ())