From 89d2fefbc663e4fc1513ca28bc2a841e0002caa8 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 16 Sep 2018 09:06:36 +0200 Subject: [PATCH] Skip leading whitespace when skipping or killing forwards When the point is on whitespace between two words skipping forward, or killing forward, should result in the new point being moved to the next word: foo bar fox gnu ^ => foo bar fox gnu ^ Before this patch the point moved to 'b'. After this patch the point moves to the first letter of the next word, 'f'. Kill forward word now properly kills 'bar' and moves to the first whitespace letter after 'bar'. Both are now behaving like FSF Readline. Signed-off-by: Joachim Nilsson --- src/editline.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/editline.c b/src/editline.c index 77f2bfa..cdac85a 100644 --- a/src/editline.c +++ b/src/editline.c @@ -378,6 +378,12 @@ static el_status_t do_forward(el_status_t move) do { p = &rl_line_buffer[rl_point]; + /* Skip leading whitespace, like FSF Readline */ + for ( ; rl_point < rl_end && (p[0] == ' ' || !is_alpha_num(p[0])); rl_point++, p++) { + if (move == CSmove) + right(CSstay); + } + /* Skip to end of word, if inside a word. */ for (; rl_point < rl_end && is_alpha_num(p[0]); rl_point++, p++) { if (move == CSmove)