edit: Fix completion at the last character

Completion needs to be done even if the full word has been entered.
In addition, fix the space-after-full-word to properly allocate room
for the extra character when completion is used in the middle of the
string.
This commit is contained in:
Jouni Malinen 2010-11-20 11:59:04 +02:00
parent 89eb6b774d
commit 414780027a

View file

@ -377,7 +377,7 @@ static void complete(int list)
} }
len = max_common_length(c); len = max_common_length(c);
if (len <= plen) { if (len < plen) {
if (list) { if (list) {
edit_clear_line(); edit_clear_line();
printf("\r"); printf("\r");
@ -396,8 +396,8 @@ static void complete(int list)
len = room; len = room;
add_space = count == 1 && len < room; add_space = count == 1 && len < room;
os_memmove(cmdbuf + cmdbuf_pos + len, cmdbuf + cmdbuf_pos, os_memmove(cmdbuf + cmdbuf_pos + len + add_space, cmdbuf + cmdbuf_pos,
cmdbuf_len - cmdbuf_pos + add_space); cmdbuf_len - cmdbuf_pos);
os_memcpy(&cmdbuf[cmdbuf_pos - plen], c[0], plen + len); os_memcpy(&cmdbuf[cmdbuf_pos - plen], c[0], plen + len);
if (add_space) if (add_space)
cmdbuf[cmdbuf_pos + len] = ' '; cmdbuf[cmdbuf_pos + len] = ' ';