mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Bug Fix - Cmd
- The two load* methods were conflicting - if loadCustomReports was called first, it stomped on the commands list and prevented loadCommands from running. Now there is only one method. - Rewrote util.cpp/autoComplete to use STL over libc. Might reduce code size.
This commit is contained in:
parent
9f1880e050
commit
b742712bb1
3 changed files with 18 additions and 24 deletions
18
src/util.cpp
18
src/util.cpp
|
@ -41,6 +41,7 @@
|
|||
#include "text.h"
|
||||
#include "main.h"
|
||||
#include "i18n.h"
|
||||
#include "util.h"
|
||||
#include "../auto.h"
|
||||
|
||||
extern Context context;
|
||||
|
@ -152,26 +153,25 @@ int autoComplete (
|
|||
const std::vector<std::string>& list,
|
||||
std::vector<std::string>& matches)
|
||||
{
|
||||
matches.erase (matches.begin (), matches.end ());
|
||||
matches.clear ();
|
||||
|
||||
// Handle trivial case.
|
||||
unsigned int length = partial.length ();
|
||||
if (length)
|
||||
{
|
||||
for (unsigned int i = 0; i < list.size (); ++i)
|
||||
foreach (item, list)
|
||||
{
|
||||
// Special case where there is an exact match.
|
||||
if (partial == list[i])
|
||||
if (partial == *item)
|
||||
{
|
||||
matches.erase (matches.begin (), matches.end ());
|
||||
matches.push_back (list[i]);
|
||||
matches.clear ();
|
||||
matches.push_back (*item);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Maintain a list of partial matches.
|
||||
if (length <= list[i].length () &&
|
||||
! strncmp (partial.c_str (), list[i].c_str (), length))
|
||||
matches.push_back (list[i]);
|
||||
if (length <= item->length () &&
|
||||
partial == item->substr (0, length))
|
||||
matches.push_back (*item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue