Fix infinite loop shell_complete

Fixes #1648
This commit is contained in:
Maxime Coste 2017-10-25 11:26:03 +08:00
parent ab9283bc37
commit 75767f5cb5

View File

@ -14,7 +14,7 @@ Completions shell_complete(const Context& context, CompletionFlags flags,
bool command = true;
const ByteCount len = prefix.length();
for (ByteCount pos = 0; pos < cursor_pos;)
for (ByteCount pos = 0; pos < cursor_pos and pos < len;)
{
command = (pos == 0 or prefix[pos-1] == ';' or prefix[pos-1] == '|' or
(pos > 1 and prefix[pos-1] == '&' and prefix[pos-2] == '&'));