edit: Fix delete_word when not in the end of line

This commit is contained in:
Jouni Malinen 2010-11-20 23:05:12 +02:00
parent ee3b84beb3
commit 31e1206baa

View file

@ -130,13 +130,17 @@ static void delete_current(void)
static void delete_word(void)
{
int pos;
edit_clear_line();
while (cmdbuf_len > 0 && cmdbuf[cmdbuf_len - 1] == ' ')
cmdbuf_len--;
while (cmdbuf_len > 0 && cmdbuf[cmdbuf_len - 1] != ' ')
cmdbuf_len--;
if (cmdbuf_pos > cmdbuf_len)
cmdbuf_pos = cmdbuf_len;
pos = cmdbuf_pos;
while (pos > 0 && cmdbuf[pos - 1] == ' ')
pos--;
while (pos > 0 && cmdbuf[pos - 1] != ' ')
pos--;
os_memmove(cmdbuf + pos, cmdbuf + cmdbuf_pos, cmdbuf_len - cmdbuf_pos);
cmdbuf_len -= cmdbuf_pos - pos;
cmdbuf_pos = pos;
edit_redraw();
}