From 96699b7ebaffbee6aac0e061fa33c7b129db5ae8 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 21 Jan 2015 10:12:08 +0300 Subject: [PATCH] Ticket #3390: fix backward word delete in input fields. How to reproduce: Either on the command line, or in any other text entry field (e.g. copy file to) enter a string where the last word consists of one single letter only. E.g. "abc de f". Press Alt+Backspace. Expected behavior: Remove the last word, that is, the letter "f" only, leaving "abc de ". Actual behavior: Yet another word is removed, leaving "abc ". Signed-off-by: Andrew Borodin --- lib/widget/input.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/widget/input.c b/lib/widget/input.c index 4ce2ddb50..97ab0f71a 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -422,13 +422,14 @@ forward_word (WInput * in) static void backward_word (WInput * in) { - const char *p, *p_tmp; + const char *p; - for (p = in->buffer + str_offset_to_pos (in->buffer, in->point); - (p != in->buffer) && (p[0] == '\0'); str_cprev_char (&p), in->point--); + p = in->buffer + str_offset_to_pos (in->buffer, in->point); while (p != in->buffer) { + const char *p_tmp; + p_tmp = p; str_cprev_char (&p); if (!str_isspace (p) && !str_ispunct (p)) -- 2.11.4.GIT