mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Expression
- Added configurable 'abbreviation.minimum' (default:2) setting to control how auto-completion works.
This commit is contained in:
parent
a6fadaee67
commit
197524a5fc
16 changed files with 139 additions and 52 deletions
12
src/util.cpp
12
src/util.cpp
|
@ -75,7 +75,7 @@ bool confirm (const std::string& question)
|
|||
std::getline (std::cin, answer);
|
||||
answer = std::cin.eof() ? STRING_UTIL_CONFIRM_NO : lowerCase (trim (answer));
|
||||
|
||||
autoComplete (answer, options, matches);
|
||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
||||
}
|
||||
while (matches.size () != 1);
|
||||
|
||||
|
@ -109,7 +109,7 @@ int confirm3 (const std::string& question)
|
|||
|
||||
std::getline (std::cin, answer);
|
||||
answer = trim (answer);
|
||||
autoComplete (answer, options, matches);
|
||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
||||
}
|
||||
while (matches.size () != 1);
|
||||
|
||||
|
@ -150,7 +150,7 @@ int confirm4 (const std::string& question)
|
|||
|
||||
std::getline (std::cin, answer);
|
||||
answer = trim (answer);
|
||||
autoComplete (answer, options, matches);
|
||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
||||
}
|
||||
while (matches.size () != 1);
|
||||
|
||||
|
@ -190,7 +190,8 @@ std::string formatBytes (size_t bytes)
|
|||
int autoComplete (
|
||||
const std::string& partial,
|
||||
const std::vector<std::string>& list,
|
||||
std::vector<std::string>& matches)
|
||||
std::vector<std::string>& matches,
|
||||
int minimum/* = 2*/)
|
||||
{
|
||||
matches.clear ();
|
||||
|
||||
|
@ -211,7 +212,8 @@ int autoComplete (
|
|||
}
|
||||
|
||||
// Maintain a list of partial matches.
|
||||
else if (length <= item->length () &&
|
||||
else if (length >= (unsigned) minimum &&
|
||||
length <= item->length () &&
|
||||
partial == item->substr (0, length))
|
||||
matches.push_back (*item);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue