Parcourir la source

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.
Jouni Malinen il y a 14 ans
Parent
commit
414780027a
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      src/utils/edit.c

+ 3 - 3
src/utils/edit.c

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